@lark-apaas/fullstack-cli 1.1.71-alpha.20261103162030 → 1.1.71-alpha.20261103174546

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +491 -222
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/index.ts
2
- import fs39 from "fs";
3
- import path34 from "path";
2
+ import fs40 from "fs";
3
+ import path35 from "path";
4
4
  import { fileURLToPath as fileURLToPath5 } from "url";
5
5
  import { config as dotenvConfig } from "dotenv";
6
6
 
@@ -4143,8 +4143,8 @@ var upgradeCommand = {
4143
4143
  };
4144
4144
 
4145
4145
  // src/commands/action-plugin/install-engine.ts
4146
- import fs22 from "fs";
4147
- import path19 from "path";
4146
+ import fs23 from "fs";
4147
+ import path20 from "path";
4148
4148
  import { spawnSync as spawnSync7 } from "child_process";
4149
4149
 
4150
4150
  // src/commands/action-plugin/plugin-files.ts
@@ -4221,8 +4221,8 @@ function assertPluginIdentity(pluginPath, expectedName, expectedVersion) {
4221
4221
  }
4222
4222
 
4223
4223
  // src/commands/action-plugin/plugin-preparation.ts
4224
- import fs19 from "fs";
4225
- import path16 from "path";
4224
+ import fs20 from "fs";
4225
+ import path17 from "path";
4226
4226
 
4227
4227
  // src/commands/action-plugin/api-client.ts
4228
4228
  import { HttpClient as HttpClient2 } from "@lark-apaas/http-client";
@@ -4709,10 +4709,242 @@ function removePathAndEmptyParents(targetPath, stopAt) {
4709
4709
  }
4710
4710
  }
4711
4711
 
4712
+ // src/commands/action-plugin/workspace-dependencies.ts
4713
+ import fs19 from "fs";
4714
+ import path16 from "path";
4715
+ var WORKSPACE_SECTIONS = [
4716
+ "dependencies",
4717
+ "optionalDependencies",
4718
+ "peerDependencies"
4719
+ ];
4720
+ function parseExactVersion(value) {
4721
+ const match = value.match(
4722
+ /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/
4723
+ );
4724
+ if (!match) return null;
4725
+ return {
4726
+ value,
4727
+ major: Number(match[1]),
4728
+ minor: Number(match[2]),
4729
+ patch: Number(match[3]),
4730
+ prerelease: match[4]?.split(".") ?? []
4731
+ };
4732
+ }
4733
+ function exactVersionFromDeclaration(spec) {
4734
+ return parseExactVersion(spec.startsWith("=") ? spec.slice(1) : spec);
4735
+ }
4736
+ function comparePrerelease(left, right) {
4737
+ if (left.length === 0 || right.length === 0) {
4738
+ if (left.length === right.length) return 0;
4739
+ return left.length === 0 ? 1 : -1;
4740
+ }
4741
+ const length = Math.max(left.length, right.length);
4742
+ for (let index = 0; index < length; index += 1) {
4743
+ const leftPart = left[index];
4744
+ const rightPart = right[index];
4745
+ if (leftPart === void 0) return -1;
4746
+ if (rightPart === void 0) return 1;
4747
+ if (leftPart === rightPart) continue;
4748
+ const leftNumeric = /^\d+$/.test(leftPart);
4749
+ const rightNumeric = /^\d+$/.test(rightPart);
4750
+ if (leftNumeric && rightNumeric)
4751
+ return Number(leftPart) - Number(rightPart);
4752
+ if (leftNumeric !== rightNumeric) return leftNumeric ? -1 : 1;
4753
+ return leftPart < rightPart ? -1 : 1;
4754
+ }
4755
+ return 0;
4756
+ }
4757
+ function compareVersions(left, right) {
4758
+ for (const key of ["major", "minor", "patch"]) {
4759
+ if (left[key] !== right[key]) return left[key] - right[key];
4760
+ }
4761
+ return comparePrerelease(left.prerelease, right.prerelease);
4762
+ }
4763
+ function satisfiesSupportedRange(version, range) {
4764
+ const exactRange = exactVersionFromDeclaration(range);
4765
+ if (exactRange) return compareVersions(version, exactRange) === 0;
4766
+ const operator = range[0];
4767
+ if (operator !== "^" && operator !== "~") return null;
4768
+ const lower = parseExactVersion(range.slice(1));
4769
+ if (!lower) return null;
4770
+ if (compareVersions(version, lower) < 0) return false;
4771
+ if (lower.prerelease.length > 0 && version.prerelease.length > 0) {
4772
+ const sameRelease = version.major === lower.major && version.minor === lower.minor && version.patch === lower.patch;
4773
+ if (!sameRelease) return false;
4774
+ }
4775
+ if (operator === "~") {
4776
+ return version.major === lower.major && version.minor === lower.minor;
4777
+ }
4778
+ if (lower.major > 0) return version.major === lower.major;
4779
+ if (lower.minor > 0) {
4780
+ return version.major === 0 && version.minor === lower.minor;
4781
+ }
4782
+ return version.major === 0 && version.minor === 0 && version.patch === lower.patch;
4783
+ }
4784
+ function validateDependencyName(name) {
4785
+ if (!/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/i.test(name)) {
4786
+ throw new Error(`unsafe dependency name ${JSON.stringify(name)}`);
4787
+ }
4788
+ }
4789
+ function hostDeclarations(hostPackage, dependency) {
4790
+ const declarations = [];
4791
+ for (const section of [
4792
+ "dependencies",
4793
+ "devDependencies",
4794
+ "optionalDependencies",
4795
+ "peerDependencies"
4796
+ ]) {
4797
+ const spec = hostPackage[section]?.[dependency];
4798
+ if (typeof spec === "string") declarations.push({ section, spec });
4799
+ }
4800
+ return declarations;
4801
+ }
4802
+ function readInstalledExactVersion(projectRoot, dependency) {
4803
+ const manifestPath = path16.join(
4804
+ projectRoot,
4805
+ "node_modules",
4806
+ dependency,
4807
+ "package.json"
4808
+ );
4809
+ if (!fs19.existsSync(manifestPath)) return null;
4810
+ let manifest;
4811
+ try {
4812
+ manifest = JSON.parse(fs19.readFileSync(manifestPath, "utf-8"));
4813
+ } catch (error) {
4814
+ throw new Error(
4815
+ `installed manifest is unreadable at ${manifestPath}: ${error instanceof Error ? error.message : String(error)}`
4816
+ );
4817
+ }
4818
+ if (manifest.name !== dependency) {
4819
+ throw new Error(
4820
+ `installed package identity mismatch at ${manifestPath}: expected ${dependency}, got ${String(manifest.name)}`
4821
+ );
4822
+ }
4823
+ if (typeof manifest.version !== "string") {
4824
+ throw new Error(
4825
+ `installed package has no exact version at ${manifestPath}`
4826
+ );
4827
+ }
4828
+ const exact = parseExactVersion(manifest.version);
4829
+ if (!exact) {
4830
+ throw new Error(
4831
+ `installed package has a non-semver version at ${manifestPath}: ${manifest.version}`
4832
+ );
4833
+ }
4834
+ return exact;
4835
+ }
4836
+ function resolveTrustedExactVersion(dependency, hostPackage, projectRoot) {
4837
+ const declaredExactVersions = hostDeclarations(hostPackage, dependency).map(({ spec }) => exactVersionFromDeclaration(spec)).filter((version) => version !== null);
4838
+ const distinctDeclaredVersions = new Map(
4839
+ declaredExactVersions.map((version) => [version.value, version])
4840
+ );
4841
+ if (distinctDeclaredVersions.size > 1) {
4842
+ throw new Error(
4843
+ `conflicting exact host declarations: ${[...distinctDeclaredVersions].join(", ")}`
4844
+ );
4845
+ }
4846
+ if (distinctDeclaredVersions.size === 1) {
4847
+ return [...distinctDeclaredVersions.values()][0];
4848
+ }
4849
+ return readInstalledExactVersion(projectRoot, dependency);
4850
+ }
4851
+ function formatContext(plugin, reference) {
4852
+ return `${reference.section}.${reference.dependency} of ${plugin.name}@${plugin.version} (${reference.spec})`;
4853
+ }
4854
+ function normalizeReference(plugin, reference, hostPackage, projectRoot) {
4855
+ validateDependencyName(reference.dependency);
4856
+ const workspaceRange = reference.spec.slice("workspace:".length);
4857
+ if (!workspaceRange) {
4858
+ throw new Error(
4859
+ `Cannot normalize workspace dependency ${formatContext(plugin, reference)}: empty workspace range`
4860
+ );
4861
+ }
4862
+ let exactVersion = null;
4863
+ const getExactVersion = () => {
4864
+ if (exactVersion === null) {
4865
+ exactVersion = resolveTrustedExactVersion(
4866
+ reference.dependency,
4867
+ hostPackage,
4868
+ projectRoot
4869
+ );
4870
+ }
4871
+ return exactVersion;
4872
+ };
4873
+ if (workspaceRange === "*" || workspaceRange === "^" || workspaceRange === "~") {
4874
+ const exact2 = getExactVersion();
4875
+ if (!exact2) {
4876
+ throw new Error(
4877
+ `Cannot normalize workspace dependency ${formatContext(plugin, reference)}: no exact host declaration or matching installed identity`
4878
+ );
4879
+ }
4880
+ return workspaceRange === "*" ? exact2.value : `${workspaceRange}${exact2.value}`;
4881
+ }
4882
+ const supportedExplicitRange = exactVersionFromDeclaration(workspaceRange) ?? (workspaceRange.startsWith("^") || workspaceRange.startsWith("~") ? parseExactVersion(workspaceRange.slice(1)) : null);
4883
+ if (!supportedExplicitRange) {
4884
+ throw new Error(
4885
+ `Cannot normalize workspace dependency ${formatContext(plugin, reference)}: unsupported workspace range ${workspaceRange}`
4886
+ );
4887
+ }
4888
+ const declarations = hostDeclarations(hostPackage, reference.dependency);
4889
+ if (declarations.some(({ spec }) => spec === workspaceRange)) {
4890
+ return workspaceRange;
4891
+ }
4892
+ const exact = getExactVersion();
4893
+ if (!exact) {
4894
+ throw new Error(
4895
+ `Cannot normalize workspace dependency ${formatContext(plugin, reference)}: host does not declare ${workspaceRange} and no matching installed identity exists`
4896
+ );
4897
+ }
4898
+ const satisfies = satisfiesSupportedRange(exact, workspaceRange);
4899
+ if (satisfies === null) {
4900
+ throw new Error(
4901
+ `Cannot normalize workspace dependency ${formatContext(plugin, reference)}: unsupported workspace range ${workspaceRange}`
4902
+ );
4903
+ }
4904
+ if (!satisfies) {
4905
+ throw new Error(
4906
+ `Cannot normalize workspace dependency ${formatContext(plugin, reference)}: installed or host identity ${exact.value} does not satisfy workspace range ${workspaceRange}`
4907
+ );
4908
+ }
4909
+ return workspaceRange;
4910
+ }
4911
+ function hasWorkspaceDependencies(manifest) {
4912
+ return WORKSPACE_SECTIONS.some(
4913
+ (section) => Object.values(manifest[section] ?? {}).some(
4914
+ (spec) => typeof spec === "string" && spec.startsWith("workspace:")
4915
+ )
4916
+ );
4917
+ }
4918
+ function normalizePluginWorkspaceDependencies(pluginPath, hostPackage, projectRoot) {
4919
+ const manifest = readPluginManifest(pluginPath);
4920
+ const nextManifest = JSON.parse(
4921
+ JSON.stringify(manifest)
4922
+ );
4923
+ let changed = false;
4924
+ for (const section of WORKSPACE_SECTIONS) {
4925
+ const dependencies = nextManifest[section];
4926
+ if (!dependencies) continue;
4927
+ for (const [dependency, spec] of Object.entries(dependencies)) {
4928
+ if (typeof spec !== "string" || !spec.startsWith("workspace:")) continue;
4929
+ dependencies[dependency] = normalizeReference(
4930
+ manifest,
4931
+ { section, dependency, spec },
4932
+ hostPackage,
4933
+ projectRoot
4934
+ );
4935
+ changed = true;
4936
+ }
4937
+ }
4938
+ if (changed) {
4939
+ atomicWriteJson(path16.join(pluginPath, "package.json"), nextManifest);
4940
+ }
4941
+ return nextManifest;
4942
+ }
4943
+
4712
4944
  // src/commands/action-plugin/plugin-preparation.ts
4713
4945
  function readPackageDocument(packageJsonPath) {
4714
4946
  return JSON.parse(
4715
- fs19.readFileSync(packageJsonPath, "utf-8")
4947
+ fs20.readFileSync(packageJsonPath, "utf-8")
4716
4948
  );
4717
4949
  }
4718
4950
  function rootDeclaresDependency(pkg2, dependency) {
@@ -4736,13 +4968,13 @@ async function defaultMaterializePlugin(name, version, destination) {
4736
4968
  tgzPath = downloaded.tgzPath;
4737
4969
  source = "download";
4738
4970
  }
4739
- fs19.mkdirSync(path16.dirname(destination), { recursive: true });
4971
+ fs20.mkdirSync(path17.dirname(destination), { recursive: true });
4740
4972
  extractTgzToDirectory(tgzPath, destination);
4741
4973
  return source;
4742
4974
  }
4743
4975
  function copyLegacyPlugin(source, destination) {
4744
- fs19.mkdirSync(path16.dirname(destination), { recursive: true });
4745
- fs19.cpSync(source, destination, {
4976
+ fs20.mkdirSync(path17.dirname(destination), { recursive: true });
4977
+ fs20.cpSync(source, destination, {
4746
4978
  recursive: true,
4747
4979
  force: true,
4748
4980
  verbatimSymlinks: true
@@ -4801,11 +5033,17 @@ async function preparePlugin(request, index, initialPackage, projectRoot, stagin
4801
5033
  );
4802
5034
  }
4803
5035
  if (managedManifest?.version === version) {
4804
- manifest = assertPluginIdentity(
4805
- managedPluginPath(projectRoot, request.name),
4806
- request.name,
4807
- version
4808
- );
5036
+ const managedPath = managedPluginPath(projectRoot, request.name);
5037
+ manifest = assertPluginIdentity(managedPath, request.name, version);
5038
+ if (hasWorkspaceDependencies(manifest)) {
5039
+ stagedPath = path17.join(stagingRoot, "prepared", String(index));
5040
+ copyLegacyPlugin(managedPath, stagedPath);
5041
+ manifest = normalizePluginWorkspaceDependencies(
5042
+ stagedPath,
5043
+ initialPackage,
5044
+ projectRoot
5045
+ );
5046
+ }
4809
5047
  source = "managed";
4810
5048
  } else {
4811
5049
  const legacyPath = findLegacyPlugin(
@@ -4814,7 +5052,7 @@ async function preparePlugin(request, index, initialPackage, projectRoot, stagin
4814
5052
  version,
4815
5053
  initialPackage
4816
5054
  );
4817
- stagedPath = path16.join(stagingRoot, "prepared", String(index));
5055
+ stagedPath = path17.join(stagingRoot, "prepared", String(index));
4818
5056
  if (legacyPath) {
4819
5057
  copyLegacyPlugin(legacyPath, stagedPath);
4820
5058
  source = "legacy";
@@ -4826,12 +5064,17 @@ async function preparePlugin(request, index, initialPackage, projectRoot, stagin
4826
5064
  );
4827
5065
  }
4828
5066
  manifest = assertPluginIdentity(stagedPath, request.name, version);
5067
+ manifest = normalizePluginWorkspaceDependencies(
5068
+ stagedPath,
5069
+ initialPackage,
5070
+ projectRoot
5071
+ );
4829
5072
  }
4830
5073
  const missingUndeclaredPeers = {};
4831
5074
  for (const [dependency, range] of Object.entries(
4832
5075
  requiredPeerDependencies(manifest)
4833
5076
  )) {
4834
- if (!lstatOrNull(path16.join(projectRoot, "node_modules", dependency)) && !rootDeclaresDependency(initialPackage, dependency)) {
5077
+ if (!lstatOrNull(path17.join(projectRoot, "node_modules", dependency)) && !rootDeclaresDependency(initialPackage, dependency)) {
4835
5078
  missingUndeclaredPeers[dependency] = range;
4836
5079
  }
4837
5080
  }
@@ -4873,13 +5116,13 @@ function collectPeerRanges(prepared) {
4873
5116
  }
4874
5117
 
4875
5118
  // src/commands/action-plugin/transaction-journal.ts
4876
- import fs20 from "fs";
4877
- import path17 from "path";
5119
+ import fs21 from "fs";
5120
+ import path18 from "path";
4878
5121
  import { randomUUID } from "crypto";
4879
5122
  var JOURNAL_FILE = ".transaction-journal.json";
4880
5123
  var TRANSACTION_DIRECTORY = ".transactions";
4881
5124
  function journalPath(projectRoot) {
4882
- return path17.join(managedRootPath(projectRoot), JOURNAL_FILE);
5125
+ return path18.join(managedRootPath(projectRoot), JOURNAL_FILE);
4883
5126
  }
4884
5127
  function isTransactionId(value) {
4885
5128
  return /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(
@@ -4890,7 +5133,7 @@ function transactionRoot(projectRoot, transactionId) {
4890
5133
  if (!isTransactionId(transactionId)) {
4891
5134
  throw new Error("Action-plugin transaction id is invalid");
4892
5135
  }
4893
- const result = path17.join(
5136
+ const result = path18.join(
4894
5137
  managedRootPath(projectRoot),
4895
5138
  TRANSACTION_DIRECTORY,
4896
5139
  transactionId
@@ -4899,14 +5142,14 @@ function transactionRoot(projectRoot, transactionId) {
4899
5142
  return result;
4900
5143
  }
4901
5144
  function snapshotFile(projectRoot, relativePath) {
4902
- const filePath = path17.join(projectRoot, relativePath);
5145
+ const filePath = path18.join(projectRoot, relativePath);
4903
5146
  assertProjectPath(projectRoot, filePath);
4904
5147
  const stats = lstatOrNull(filePath);
4905
5148
  if (!stats) return { relativePath, content: null, mode: null };
4906
5149
  if (!stats.isFile()) throw new Error(`Expected a regular file: ${filePath}`);
4907
5150
  return {
4908
5151
  relativePath,
4909
- content: fs20.readFileSync(filePath).toString("base64"),
5152
+ content: fs21.readFileSync(filePath).toString("base64"),
4910
5153
  mode: stats.mode
4911
5154
  };
4912
5155
  }
@@ -4928,20 +5171,20 @@ function snapshotEntry(projectRoot, transactionId, name, location, index) {
4928
5171
  location,
4929
5172
  kind: "symlink",
4930
5173
  backupRelativePath: null,
4931
- linkTarget: fs20.readlinkSync(targetPath)
5174
+ linkTarget: fs21.readlinkSync(targetPath)
4932
5175
  };
4933
5176
  }
4934
- const relativeBackup = path17.join(
5177
+ const relativeBackup = path18.join(
4935
5178
  TRANSACTION_DIRECTORY,
4936
5179
  transactionId,
4937
5180
  "entries",
4938
5181
  String(index)
4939
5182
  );
4940
- const backupPath = path17.join(managedRootPath(projectRoot), relativeBackup);
5183
+ const backupPath = path18.join(managedRootPath(projectRoot), relativeBackup);
4941
5184
  assertProjectPath(projectRoot, backupPath);
4942
- fs20.mkdirSync(path17.dirname(backupPath), { recursive: true });
5185
+ fs21.mkdirSync(path18.dirname(backupPath), { recursive: true });
4943
5186
  if (stats.isDirectory()) {
4944
- fs20.cpSync(targetPath, backupPath, {
5187
+ fs21.cpSync(targetPath, backupPath, {
4945
5188
  recursive: true,
4946
5189
  force: true,
4947
5190
  verbatimSymlinks: true
@@ -4955,7 +5198,7 @@ function snapshotEntry(projectRoot, transactionId, name, location, index) {
4955
5198
  };
4956
5199
  }
4957
5200
  if (stats.isFile()) {
4958
- fs20.copyFileSync(targetPath, backupPath);
5201
+ fs21.copyFileSync(targetPath, backupPath);
4959
5202
  return {
4960
5203
  name,
4961
5204
  location,
@@ -4974,7 +5217,7 @@ function beginActionPluginTransaction(projectRootInput, pluginNames) {
4974
5217
  }
4975
5218
  const managedRootExisted = Boolean(lstatOrNull(managedRootPath(projectRoot)));
4976
5219
  const transactionId = randomUUID();
4977
- fs20.mkdirSync(transactionRoot(projectRoot, transactionId), {
5220
+ fs21.mkdirSync(transactionRoot(projectRoot, transactionId), {
4978
5221
  recursive: true
4979
5222
  });
4980
5223
  try {
@@ -5006,41 +5249,41 @@ function beginActionPluginTransaction(projectRootInput, pluginNames) {
5006
5249
  atomicWriteJson(journalPath(projectRoot), journal);
5007
5250
  return journal;
5008
5251
  } catch (error) {
5009
- fs20.rmSync(transactionRoot(projectRoot, transactionId), {
5252
+ fs21.rmSync(transactionRoot(projectRoot, transactionId), {
5010
5253
  recursive: true,
5011
5254
  force: true
5012
5255
  });
5013
- const transactionsPath = path17.join(
5256
+ const transactionsPath = path18.join(
5014
5257
  managedRootPath(projectRoot),
5015
5258
  TRANSACTION_DIRECTORY
5016
5259
  );
5017
- if (fs20.existsSync(transactionsPath) && fs20.readdirSync(transactionsPath).length === 0) {
5018
- fs20.rmdirSync(transactionsPath);
5260
+ if (fs21.existsSync(transactionsPath) && fs21.readdirSync(transactionsPath).length === 0) {
5261
+ fs21.rmdirSync(transactionsPath);
5019
5262
  }
5020
- if (!managedRootExisted && fs20.existsSync(managedRootPath(projectRoot)) && fs20.readdirSync(managedRootPath(projectRoot)).length === 0) {
5021
- fs20.rmdirSync(managedRootPath(projectRoot));
5263
+ if (!managedRootExisted && fs21.existsSync(managedRootPath(projectRoot)) && fs21.readdirSync(managedRootPath(projectRoot)).length === 0) {
5264
+ fs21.rmdirSync(managedRootPath(projectRoot));
5022
5265
  }
5023
5266
  throw error;
5024
5267
  }
5025
5268
  }
5026
5269
  function restoreFile(projectRoot, snapshot) {
5027
- const filePath = path17.join(projectRoot, snapshot.relativePath);
5270
+ const filePath = path18.join(projectRoot, snapshot.relativePath);
5028
5271
  assertProjectPath(projectRoot, filePath);
5029
5272
  if (snapshot.content === null) {
5030
5273
  if (lstatOrNull(filePath))
5031
- fs20.rmSync(filePath, { recursive: true, force: true });
5274
+ fs21.rmSync(filePath, { recursive: true, force: true });
5032
5275
  return;
5033
5276
  }
5034
5277
  atomicWriteFile(filePath, Buffer.from(snapshot.content, "base64"));
5035
- if (snapshot.mode !== null) fs20.chmodSync(filePath, snapshot.mode);
5278
+ if (snapshot.mode !== null) fs21.chmodSync(filePath, snapshot.mode);
5036
5279
  }
5037
5280
  function removeEntry(targetPath) {
5038
5281
  const stats = lstatOrNull(targetPath);
5039
5282
  if (!stats) return;
5040
5283
  if (stats.isDirectory() && !stats.isSymbolicLink()) {
5041
- fs20.rmSync(targetPath, { recursive: true, force: true });
5284
+ fs21.rmSync(targetPath, { recursive: true, force: true });
5042
5285
  } else {
5043
- fs20.unlinkSync(targetPath);
5286
+ fs21.unlinkSync(targetPath);
5044
5287
  }
5045
5288
  }
5046
5289
  function restoreEntry(projectRoot, journal, snapshot) {
@@ -5048,54 +5291,54 @@ function restoreEntry(projectRoot, journal, snapshot) {
5048
5291
  const targetPath = snapshot.location === "source" ? managedPluginPath(projectRoot, snapshot.name) : nodePluginPath(projectRoot, snapshot.name);
5049
5292
  removeEntry(targetPath);
5050
5293
  if (snapshot.kind === "missing") return;
5051
- fs20.mkdirSync(path17.dirname(targetPath), { recursive: true });
5294
+ fs21.mkdirSync(path18.dirname(targetPath), { recursive: true });
5052
5295
  if (snapshot.kind === "symlink") {
5053
5296
  if (snapshot.linkTarget === null)
5054
5297
  throw new Error("Journal symlink target is missing");
5055
- fs20.symlinkSync(snapshot.linkTarget, targetPath);
5298
+ fs21.symlinkSync(snapshot.linkTarget, targetPath);
5056
5299
  return;
5057
5300
  }
5058
5301
  if (snapshot.backupRelativePath === null) {
5059
5302
  throw new Error("Journal entry backup is missing");
5060
5303
  }
5061
- const expectedPrefix = path17.join(
5304
+ const expectedPrefix = path18.join(
5062
5305
  TRANSACTION_DIRECTORY,
5063
5306
  journal.transactionId,
5064
5307
  "entries"
5065
5308
  );
5066
- if (snapshot.backupRelativePath !== expectedPrefix && !snapshot.backupRelativePath.startsWith(`${expectedPrefix}${path17.sep}`)) {
5309
+ if (snapshot.backupRelativePath !== expectedPrefix && !snapshot.backupRelativePath.startsWith(`${expectedPrefix}${path18.sep}`)) {
5067
5310
  throw new Error("Journal entry backup path is invalid");
5068
5311
  }
5069
- const backupPath = path17.join(
5312
+ const backupPath = path18.join(
5070
5313
  managedRootPath(projectRoot),
5071
5314
  snapshot.backupRelativePath
5072
5315
  );
5073
5316
  assertProjectPath(projectRoot, backupPath);
5074
5317
  if (snapshot.kind === "directory") {
5075
- fs20.cpSync(backupPath, targetPath, {
5318
+ fs21.cpSync(backupPath, targetPath, {
5076
5319
  recursive: true,
5077
5320
  force: true,
5078
5321
  verbatimSymlinks: true
5079
5322
  });
5080
5323
  } else {
5081
- fs20.copyFileSync(backupPath, targetPath);
5324
+ fs21.copyFileSync(backupPath, targetPath);
5082
5325
  }
5083
5326
  }
5084
5327
  function removeTransactionArtifacts(projectRoot, journal) {
5085
- fs20.rmSync(journalPath(projectRoot), { force: true });
5086
- fs20.rmSync(transactionRoot(projectRoot, journal.transactionId), {
5328
+ fs21.rmSync(journalPath(projectRoot), { force: true });
5329
+ fs21.rmSync(transactionRoot(projectRoot, journal.transactionId), {
5087
5330
  recursive: true,
5088
5331
  force: true
5089
5332
  });
5090
- const transactionsPath = path17.join(
5333
+ const transactionsPath = path18.join(
5091
5334
  managedRootPath(projectRoot),
5092
5335
  TRANSACTION_DIRECTORY
5093
5336
  );
5094
- if (fs20.existsSync(transactionsPath) && fs20.readdirSync(transactionsPath).length === 0) {
5095
- fs20.rmdirSync(transactionsPath);
5337
+ if (fs21.existsSync(transactionsPath) && fs21.readdirSync(transactionsPath).length === 0) {
5338
+ fs21.rmdirSync(transactionsPath);
5096
5339
  }
5097
- if (!journal.managedRootExisted && fs20.existsSync(managedRootPath(projectRoot)) && fs20.readdirSync(managedRootPath(projectRoot)).length === 0) {
5098
- fs20.rmdirSync(managedRootPath(projectRoot));
5340
+ if (!journal.managedRootExisted && fs21.existsSync(managedRootPath(projectRoot)) && fs21.readdirSync(managedRootPath(projectRoot)).length === 0) {
5341
+ fs21.rmdirSync(managedRootPath(projectRoot));
5099
5342
  }
5100
5343
  }
5101
5344
  function rollbackActionPluginTransaction(journal) {
@@ -5108,7 +5351,7 @@ function rollbackActionPluginTransaction(journal) {
5108
5351
  restoreEntry(projectRoot, journal, snapshot);
5109
5352
  }
5110
5353
  if (!journal.managedRootExisted) {
5111
- fs20.rmSync(managedRootPath(projectRoot), { recursive: true, force: true });
5354
+ fs21.rmSync(managedRootPath(projectRoot), { recursive: true, force: true });
5112
5355
  } else {
5113
5356
  removeTransactionArtifacts(projectRoot, journal);
5114
5357
  }
@@ -5123,7 +5366,7 @@ function recoverInterruptedActionPluginTransaction(projectRootInput) {
5123
5366
  const currentJournalPath = journalPath(projectRoot);
5124
5367
  if (!lstatOrNull(currentJournalPath)) return false;
5125
5368
  const journal = JSON.parse(
5126
- fs20.readFileSync(currentJournalPath, "utf-8")
5369
+ fs21.readFileSync(currentJournalPath, "utf-8")
5127
5370
  );
5128
5371
  if (journal.schemaVersion !== 1 || journal.projectRoot !== projectRoot || !isTransactionId(journal.transactionId)) {
5129
5372
  throw new Error("Action-plugin transaction journal is invalid");
@@ -5133,8 +5376,8 @@ function recoverInterruptedActionPluginTransaction(projectRootInput) {
5133
5376
  }
5134
5377
 
5135
5378
  // src/commands/action-plugin/utils.ts
5136
- import fs21 from "fs";
5137
- import path18 from "path";
5379
+ import fs22 from "fs";
5380
+ import path19 from "path";
5138
5381
  import { spawnSync as spawnSync6, execSync as execSync2 } from "child_process";
5139
5382
  function parsePluginName(input) {
5140
5383
  const match = input.match(
@@ -5154,15 +5397,15 @@ function getProjectRoot() {
5154
5397
  return process.cwd();
5155
5398
  }
5156
5399
  function getPackageJsonPath() {
5157
- return path18.join(getProjectRoot(), "package.json");
5400
+ return path19.join(getProjectRoot(), "package.json");
5158
5401
  }
5159
5402
  function readPackageJson2() {
5160
5403
  const pkgPath = getPackageJsonPath();
5161
- if (!fs21.existsSync(pkgPath)) {
5404
+ if (!fs22.existsSync(pkgPath)) {
5162
5405
  throw new Error("package.json not found in current directory");
5163
5406
  }
5164
5407
  try {
5165
- const content = fs21.readFileSync(pkgPath, "utf-8");
5408
+ const content = fs22.readFileSync(pkgPath, "utf-8");
5166
5409
  return JSON.parse(content);
5167
5410
  } catch {
5168
5411
  throw new Error("Failed to parse package.json");
@@ -5218,7 +5461,7 @@ async function executePluginBatch(requests, mode, options = {}) {
5218
5461
  const projectRoot = resolveProjectRoot(options.projectRoot ?? process.cwd());
5219
5462
  assertManagedRoot(projectRoot);
5220
5463
  recoverInterruptedActionPluginTransaction(projectRoot);
5221
- const packageJsonPath = path19.join(projectRoot, "package.json");
5464
+ const packageJsonPath = path20.join(projectRoot, "package.json");
5222
5465
  const initialPackage = readPackageDocument(packageJsonPath);
5223
5466
  const stagingRoot = createStagingRoot();
5224
5467
  const results = /* @__PURE__ */ new Map();
@@ -5435,7 +5678,7 @@ async function executePluginBatch(requests, mode, options = {}) {
5435
5678
  }
5436
5679
  for (const [index, plugin] of publicPrepared) {
5437
5680
  const oldVersion = initialPackage.actionPlugins?.[plugin.name];
5438
- const skipped = oldVersion === plugin.version && initialPackage.dependencies?.[plugin.name] === localDependencySpec(plugin.name) && plugin.source === "managed";
5681
+ const skipped = oldVersion === plugin.version && initialPackage.dependencies?.[plugin.name] === localDependencySpec(plugin.name) && plugin.source === "managed" && plugin.stagedPath === null;
5439
5682
  results.set(index, {
5440
5683
  name: plugin.name,
5441
5684
  version: plugin.version,
@@ -5461,7 +5704,7 @@ async function executePluginBatch(requests, mode, options = {}) {
5461
5704
  }
5462
5705
  );
5463
5706
  } finally {
5464
- fs22.rmSync(stagingRoot, { recursive: true, force: true });
5707
+ fs23.rmSync(stagingRoot, { recursive: true, force: true });
5465
5708
  }
5466
5709
  }
5467
5710
  async function installPluginBatch(namesWithVersions, options = {}) {
@@ -5498,8 +5741,8 @@ async function updatePluginBatch(names, options = {}) {
5498
5741
  }
5499
5742
 
5500
5743
  // src/commands/action-plugin/restore.handler.ts
5501
- import fs23 from "fs";
5502
- import path20 from "path";
5744
+ import fs24 from "fs";
5745
+ import path21 from "path";
5503
5746
  async function defaultMaterializePlugin2(name, version, destination) {
5504
5747
  let tgzPath;
5505
5748
  if (hasCachedPlugin(name, version)) {
@@ -5513,13 +5756,13 @@ async function defaultMaterializePlugin2(name, version, destination) {
5513
5756
  }
5514
5757
  tgzPath = downloaded.tgzPath;
5515
5758
  }
5516
- fs23.mkdirSync(path20.dirname(destination), { recursive: true });
5759
+ fs24.mkdirSync(path21.dirname(destination), { recursive: true });
5517
5760
  extractTgzToDirectory(tgzPath, destination);
5518
5761
  }
5519
5762
  function assertRequiredPeers(projectRoot, pluginPath) {
5520
5763
  const manifest = readPluginManifest(pluginPath);
5521
5764
  const missing = Object.keys(requiredPeerDependencies(manifest)).filter(
5522
- (peer) => !lstatOrNull(path20.join(projectRoot, "node_modules", peer))
5765
+ (peer) => !lstatOrNull(path21.join(projectRoot, "node_modules", peer))
5523
5766
  );
5524
5767
  if (missing.length > 0) {
5525
5768
  throw new Error(`Missing peer dependencies: ${missing.join(", ")}`);
@@ -5530,7 +5773,7 @@ async function restoreActionPlugins(plugins, options = {}) {
5530
5773
  assertManagedRoot(projectRoot);
5531
5774
  recoverInterruptedActionPluginTransaction(projectRoot);
5532
5775
  const packageDocument = readPackageDocument(
5533
- path20.join(projectRoot, "package.json")
5776
+ path21.join(projectRoot, "package.json")
5534
5777
  );
5535
5778
  const stagingRoot = createStagingRoot();
5536
5779
  const entries = Object.entries(plugins);
@@ -5545,10 +5788,10 @@ async function restoreActionPlugins(plugins, options = {}) {
5545
5788
  if (graphBacked) assertManagedSourcePath(projectRoot, name);
5546
5789
  if (lstatOrNull(targetPath)) {
5547
5790
  try {
5548
- const existingManifest = readPluginManifest(targetPath);
5549
- if (existingManifest.name !== name) {
5791
+ const existingManifest2 = readPluginManifest(targetPath);
5792
+ if (existingManifest2.name !== name) {
5550
5793
  throw new Error(
5551
- `Plugin identity mismatch: expected ${name}, got ${existingManifest.name}`
5794
+ `Plugin identity mismatch: expected ${name}, got ${existingManifest2.name}`
5552
5795
  );
5553
5796
  }
5554
5797
  } catch (error) {
@@ -5557,25 +5800,51 @@ async function restoreActionPlugins(plugins, options = {}) {
5557
5800
  }
5558
5801
  }
5559
5802
  }
5803
+ let existingManifest = null;
5560
5804
  try {
5561
- assertPluginIdentity(targetPath, name, version);
5805
+ const exactManifest = assertPluginIdentity(targetPath, name, version);
5562
5806
  assertRequiredPeers(projectRoot, targetPath);
5563
- results.set(index, {
5564
- name,
5565
- version,
5566
- success: true,
5567
- skipped: true
5568
- });
5569
- continue;
5807
+ existingManifest = exactManifest;
5570
5808
  } catch {
5571
5809
  }
5572
- const stagedPath = path20.join(stagingRoot, "prepared", String(index));
5810
+ const stagedPath = path21.join(stagingRoot, "prepared", String(index));
5811
+ if (existingManifest) {
5812
+ if (graphBacked && hasWorkspaceDependencies(existingManifest)) {
5813
+ fs24.mkdirSync(path21.dirname(stagedPath), { recursive: true });
5814
+ fs24.cpSync(targetPath, stagedPath, {
5815
+ recursive: true,
5816
+ force: true,
5817
+ verbatimSymlinks: true
5818
+ });
5819
+ normalizePluginWorkspaceDependencies(
5820
+ stagedPath,
5821
+ packageDocument,
5822
+ projectRoot
5823
+ );
5824
+ prepared.push({ index, name, version, stagedPath, targetPath });
5825
+ } else {
5826
+ results.set(index, {
5827
+ name,
5828
+ version,
5829
+ success: true,
5830
+ skipped: true
5831
+ });
5832
+ }
5833
+ continue;
5834
+ }
5573
5835
  await (options.materializePlugin ?? defaultMaterializePlugin2)(
5574
5836
  name,
5575
5837
  version,
5576
5838
  stagedPath
5577
5839
  );
5578
5840
  assertPluginIdentity(stagedPath, name, version);
5841
+ if (graphBacked) {
5842
+ normalizePluginWorkspaceDependencies(
5843
+ stagedPath,
5844
+ packageDocument,
5845
+ projectRoot
5846
+ );
5847
+ }
5579
5848
  assertRequiredPeers(projectRoot, stagedPath);
5580
5849
  prepared.push({ index, name, version, stagedPath, targetPath });
5581
5850
  } catch (error) {
@@ -5653,7 +5922,7 @@ async function restoreActionPlugins(plugins, options = {}) {
5653
5922
  }
5654
5923
  );
5655
5924
  } finally {
5656
- fs23.rmSync(stagingRoot, { recursive: true, force: true });
5925
+ fs24.rmSync(stagingRoot, { recursive: true, force: true });
5657
5926
  }
5658
5927
  }
5659
5928
  async function restore(options = {}) {
@@ -5839,14 +6108,14 @@ function printSummary(results) {
5839
6108
  }
5840
6109
 
5841
6110
  // src/commands/action-plugin/remove.handler.ts
5842
- import fs24 from "fs";
5843
- import path21 from "path";
6111
+ import fs25 from "fs";
6112
+ import path22 from "path";
5844
6113
  async function removePluginGraph(nameWithVersion, options = {}) {
5845
6114
  const projectRoot = resolveProjectRoot(options.projectRoot ?? process.cwd());
5846
6115
  assertManagedRoot(projectRoot);
5847
6116
  recoverInterruptedActionPluginTransaction(projectRoot);
5848
6117
  const { name } = parsePluginName(nameWithVersion);
5849
- const packageJsonPath = path21.join(projectRoot, "package.json");
6118
+ const packageJsonPath = path22.join(projectRoot, "package.json");
5850
6119
  const initialPackage = readPackageDocument(packageJsonPath);
5851
6120
  if (!initialPackage.actionPlugins?.[name]) {
5852
6121
  throw new Error(`Plugin ${name} is not installed`);
@@ -5870,7 +6139,7 @@ async function removePluginGraph(nameWithVersion, options = {}) {
5870
6139
  removePluginLockEntries(projectRoot, name);
5871
6140
  removePathAndEmptyParents(
5872
6141
  nodePluginPath(projectRoot, name),
5873
- path21.join(projectRoot, "node_modules")
6142
+ path22.join(projectRoot, "node_modules")
5874
6143
  );
5875
6144
  removePathAndEmptyParents(
5876
6145
  managedPluginPath(projectRoot, name),
@@ -5885,8 +6154,8 @@ async function removePluginGraph(nameWithVersion, options = {}) {
5885
6154
  throw new Error(`Plugin removal left managed state for ${name}`);
5886
6155
  }
5887
6156
  const lockPath = findLockfilePath(projectRoot);
5888
- if (fs24.existsSync(lockPath)) {
5889
- const lock = JSON.parse(fs24.readFileSync(lockPath, "utf-8"));
6157
+ if (fs25.existsSync(lockPath)) {
6158
+ const lock = JSON.parse(fs25.readFileSync(lockPath, "utf-8"));
5890
6159
  if (lock.packages?.[sourceLockKey(name)] || lock.packages?.[nodeLockKey(name)]) {
5891
6160
  throw new Error(`Plugin removal left lock state for ${name}`);
5892
6161
  }
@@ -5903,8 +6172,8 @@ async function removePluginGraph(nameWithVersion, options = {}) {
5903
6172
  throw error;
5904
6173
  }
5905
6174
  const committedPackage = readPackageDocument(packageJsonPath);
5906
- if (Object.keys(committedPackage.actionPlugins ?? {}).length === 0 && fs24.existsSync(managedRootPath(projectRoot))) {
5907
- fs24.rmSync(managedRootPath(projectRoot), { recursive: true, force: true });
6175
+ if (Object.keys(committedPackage.actionPlugins ?? {}).length === 0 && fs25.existsSync(managedRootPath(projectRoot))) {
6176
+ fs25.rmSync(managedRootPath(projectRoot), { recursive: true, force: true });
5908
6177
  }
5909
6178
  }
5910
6179
  async function remove(nameWithVersion, options = {}) {
@@ -6108,45 +6377,45 @@ var actionPluginCommandGroup = {
6108
6377
  };
6109
6378
 
6110
6379
  // src/commands/capability/utils.ts
6111
- import fs25 from "fs";
6380
+ import fs26 from "fs";
6112
6381
  import { createRequire as createRequire3 } from "module";
6113
- import path22 from "path";
6382
+ import path23 from "path";
6114
6383
  var CAPABILITIES_DIR = "server/capabilities";
6115
6384
  var SHARED_CAPABILITIES_DIR = "shared/capabilities";
6116
6385
  function getProjectRoot2() {
6117
6386
  return process.cwd();
6118
6387
  }
6119
6388
  function getCapabilitiesDir() {
6120
- const sharedDir = path22.join(getProjectRoot2(), SHARED_CAPABILITIES_DIR);
6121
- if (fs25.existsSync(sharedDir)) {
6389
+ const sharedDir = path23.join(getProjectRoot2(), SHARED_CAPABILITIES_DIR);
6390
+ if (fs26.existsSync(sharedDir)) {
6122
6391
  return sharedDir;
6123
6392
  }
6124
- return path22.join(getProjectRoot2(), CAPABILITIES_DIR);
6393
+ return path23.join(getProjectRoot2(), CAPABILITIES_DIR);
6125
6394
  }
6126
6395
  function getCapabilityPath(id) {
6127
- return path22.join(getCapabilitiesDir(), `${id}.json`);
6396
+ return path23.join(getCapabilitiesDir(), `${id}.json`);
6128
6397
  }
6129
6398
  function getPluginManifestPath(pluginKey) {
6130
- return path22.join(getProjectRoot2(), "node_modules", pluginKey, "manifest.json");
6399
+ return path23.join(getProjectRoot2(), "node_modules", pluginKey, "manifest.json");
6131
6400
  }
6132
6401
  function capabilitiesDirExists() {
6133
- return fs25.existsSync(getCapabilitiesDir());
6402
+ return fs26.existsSync(getCapabilitiesDir());
6134
6403
  }
6135
6404
  function listCapabilityIds() {
6136
6405
  const dir = getCapabilitiesDir();
6137
- if (!fs25.existsSync(dir)) {
6406
+ if (!fs26.existsSync(dir)) {
6138
6407
  return [];
6139
6408
  }
6140
- const files = fs25.readdirSync(dir);
6409
+ const files = fs26.readdirSync(dir);
6141
6410
  return files.filter((f) => f.endsWith(".json") && f !== "capabilities.json").map((f) => f.replace(/\.json$/, ""));
6142
6411
  }
6143
6412
  function readCapability(id) {
6144
6413
  const filePath = getCapabilityPath(id);
6145
- if (!fs25.existsSync(filePath)) {
6414
+ if (!fs26.existsSync(filePath)) {
6146
6415
  throw new Error(`Capability not found: ${id}`);
6147
6416
  }
6148
6417
  try {
6149
- const content = fs25.readFileSync(filePath, "utf-8");
6418
+ const content = fs26.readFileSync(filePath, "utf-8");
6150
6419
  return JSON.parse(content);
6151
6420
  } catch (error) {
6152
6421
  if (error instanceof SyntaxError) {
@@ -6173,11 +6442,11 @@ function readAllCapabilities() {
6173
6442
  }
6174
6443
  function readPluginManifest3(pluginKey) {
6175
6444
  const manifestPath = getPluginManifestPath(pluginKey);
6176
- if (!fs25.existsSync(manifestPath)) {
6445
+ if (!fs26.existsSync(manifestPath)) {
6177
6446
  throw new Error(`Plugin not installed: ${pluginKey} (manifest.json not found)`);
6178
6447
  }
6179
6448
  try {
6180
- const content = fs25.readFileSync(manifestPath, "utf-8");
6449
+ const content = fs26.readFileSync(manifestPath, "utf-8");
6181
6450
  return JSON.parse(content);
6182
6451
  } catch (error) {
6183
6452
  if (error instanceof SyntaxError) {
@@ -6194,7 +6463,7 @@ function hasValidParamsSchema(paramsSchema) {
6194
6463
  }
6195
6464
  async function loadPlugin(pluginKey) {
6196
6465
  try {
6197
- const userRequire = createRequire3(path22.join(getProjectRoot2(), "package.json"));
6466
+ const userRequire = createRequire3(path23.join(getProjectRoot2(), "package.json"));
6198
6467
  const resolvedPath = userRequire.resolve(pluginKey);
6199
6468
  const pluginModule = await import(resolvedPath);
6200
6469
  const pluginPackage = pluginModule.default ?? pluginModule;
@@ -6357,8 +6626,8 @@ var capabilityCommandGroup = {
6357
6626
  import { execFile } from "child_process";
6358
6627
 
6359
6628
  // src/commands/component/registry-preparer.ts
6360
- import fs26 from "fs";
6361
- import path23 from "path";
6629
+ import fs27 from "fs";
6630
+ import path24 from "path";
6362
6631
  import os2 from "os";
6363
6632
 
6364
6633
  // src/commands/component/service.ts
@@ -6418,7 +6687,7 @@ async function sendInstallEvent(key) {
6418
6687
  }
6419
6688
 
6420
6689
  // src/commands/component/registry-preparer.ts
6421
- var REGISTRY_TEMP_DIR = path23.join(os2.tmpdir(), "miaoda-registry");
6690
+ var REGISTRY_TEMP_DIR = path24.join(os2.tmpdir(), "miaoda-registry");
6422
6691
  function parseComponentKey(key) {
6423
6692
  const match = key.match(/^@([^/]+)\/(.+)$/);
6424
6693
  if (!match) {
@@ -6430,11 +6699,11 @@ function parseComponentKey(key) {
6430
6699
  }
6431
6700
  function getLocalRegistryPath(key) {
6432
6701
  const { scope, name } = parseComponentKey(key);
6433
- return path23.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
6702
+ return path24.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
6434
6703
  }
6435
6704
  function ensureDir(dirPath) {
6436
- if (!fs26.existsSync(dirPath)) {
6437
- fs26.mkdirSync(dirPath, { recursive: true });
6705
+ if (!fs27.existsSync(dirPath)) {
6706
+ fs27.mkdirSync(dirPath, { recursive: true });
6438
6707
  }
6439
6708
  }
6440
6709
  async function prepareRecursive(key, visited) {
@@ -6467,8 +6736,8 @@ async function prepareRecursive(key, visited) {
6467
6736
  registryDependencies: deps.map((dep) => getLocalRegistryPath(dep))
6468
6737
  };
6469
6738
  const localPath = getLocalRegistryPath(key);
6470
- ensureDir(path23.dirname(localPath));
6471
- fs26.writeFileSync(localPath, JSON.stringify(rewrittenItem, null, 2), "utf-8");
6739
+ ensureDir(path24.dirname(localPath));
6740
+ fs27.writeFileSync(localPath, JSON.stringify(rewrittenItem, null, 2), "utf-8");
6472
6741
  debug("\u4FDD\u5B58\u5230: %s", localPath);
6473
6742
  }
6474
6743
  async function prepareComponentRegistryItems(id) {
@@ -6478,18 +6747,18 @@ async function prepareComponentRegistryItems(id) {
6478
6747
  }
6479
6748
  function cleanupTempDir() {
6480
6749
  try {
6481
- if (fs26.existsSync(REGISTRY_TEMP_DIR)) {
6482
- fs26.rmSync(REGISTRY_TEMP_DIR, { recursive: true, force: true });
6750
+ if (fs27.existsSync(REGISTRY_TEMP_DIR)) {
6751
+ fs27.rmSync(REGISTRY_TEMP_DIR, { recursive: true, force: true });
6483
6752
  }
6484
6753
  } catch {
6485
6754
  }
6486
6755
  }
6487
6756
  function getDownloadedRegistryItem(itemId) {
6488
6757
  const localPath = getLocalRegistryPath(itemId);
6489
- if (!fs26.existsSync(localPath)) {
6758
+ if (!fs27.existsSync(localPath)) {
6490
6759
  return null;
6491
6760
  }
6492
- const content = fs26.readFileSync(localPath, "utf-8");
6761
+ const content = fs27.readFileSync(localPath, "utf-8");
6493
6762
  return JSON.parse(content);
6494
6763
  }
6495
6764
 
@@ -6657,58 +6926,58 @@ var componentCommandGroup = {
6657
6926
  };
6658
6927
 
6659
6928
  // src/commands/migration/version-manager.ts
6660
- import fs27 from "fs";
6661
- import path24 from "path";
6929
+ import fs28 from "fs";
6930
+ import path25 from "path";
6662
6931
  var PACKAGE_JSON = "package.json";
6663
6932
  var VERSION_FIELD = "migrationVersion";
6664
6933
  function getPackageJsonPath2() {
6665
- return path24.join(process.cwd(), PACKAGE_JSON);
6934
+ return path25.join(process.cwd(), PACKAGE_JSON);
6666
6935
  }
6667
6936
  function getCurrentVersion() {
6668
6937
  const pkgPath = getPackageJsonPath2();
6669
- if (!fs27.existsSync(pkgPath)) {
6938
+ if (!fs28.existsSync(pkgPath)) {
6670
6939
  throw new Error("package.json not found");
6671
6940
  }
6672
- const pkg2 = JSON.parse(fs27.readFileSync(pkgPath, "utf-8"));
6941
+ const pkg2 = JSON.parse(fs28.readFileSync(pkgPath, "utf-8"));
6673
6942
  return pkg2[VERSION_FIELD] ?? 0;
6674
6943
  }
6675
6944
  function setCurrentVersion(version) {
6676
6945
  const pkgPath = getPackageJsonPath2();
6677
- const pkg2 = JSON.parse(fs27.readFileSync(pkgPath, "utf-8"));
6946
+ const pkg2 = JSON.parse(fs28.readFileSync(pkgPath, "utf-8"));
6678
6947
  pkg2[VERSION_FIELD] = version;
6679
- fs27.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
6948
+ fs28.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
6680
6949
  }
6681
6950
 
6682
6951
  // src/commands/migration/versions/v001_capability/json-migrator/detector.ts
6683
- import fs29 from "fs";
6684
- import path26 from "path";
6952
+ import fs30 from "fs";
6953
+ import path27 from "path";
6685
6954
 
6686
6955
  // src/commands/migration/versions/v001_capability/utils.ts
6687
- import fs28 from "fs";
6688
- import path25 from "path";
6956
+ import fs29 from "fs";
6957
+ import path26 from "path";
6689
6958
  var CAPABILITIES_DIR2 = "server/capabilities";
6690
6959
  function getProjectRoot3() {
6691
6960
  return process.cwd();
6692
6961
  }
6693
6962
  function getCapabilitiesDir2() {
6694
- return path25.join(getProjectRoot3(), CAPABILITIES_DIR2);
6963
+ return path26.join(getProjectRoot3(), CAPABILITIES_DIR2);
6695
6964
  }
6696
6965
  function getPluginManifestPath2(pluginKey) {
6697
- return path25.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
6966
+ return path26.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
6698
6967
  }
6699
6968
 
6700
6969
  // src/commands/migration/versions/v001_capability/json-migrator/detector.ts
6701
6970
  function detectJsonMigration() {
6702
6971
  const capabilitiesDir = getCapabilitiesDir2();
6703
- const oldFilePath = path26.join(capabilitiesDir, "capabilities.json");
6704
- if (!fs29.existsSync(oldFilePath)) {
6972
+ const oldFilePath = path27.join(capabilitiesDir, "capabilities.json");
6973
+ if (!fs30.existsSync(oldFilePath)) {
6705
6974
  return {
6706
6975
  needsMigration: false,
6707
6976
  reason: "capabilities.json not found"
6708
6977
  };
6709
6978
  }
6710
6979
  try {
6711
- const content = fs29.readFileSync(oldFilePath, "utf-8");
6980
+ const content = fs30.readFileSync(oldFilePath, "utf-8");
6712
6981
  const parsed = JSON.parse(content);
6713
6982
  if (!Array.isArray(parsed)) {
6714
6983
  return {
@@ -6759,8 +7028,8 @@ async function check(options) {
6759
7028
  }
6760
7029
 
6761
7030
  // src/commands/migration/versions/v001_capability/json-migrator/index.ts
6762
- import fs30 from "fs";
6763
- import path27 from "path";
7031
+ import fs31 from "fs";
7032
+ import path28 from "path";
6764
7033
 
6765
7034
  // src/commands/migration/versions/v001_capability/mapping.ts
6766
7035
  var DEFAULT_PLUGIN_VERSION = "1.0.0";
@@ -6990,18 +7259,18 @@ function transformCapabilities(oldCapabilities) {
6990
7259
  // src/commands/migration/versions/v001_capability/json-migrator/index.ts
6991
7260
  function loadExistingCapabilities() {
6992
7261
  const capabilitiesDir = getCapabilitiesDir2();
6993
- if (!fs30.existsSync(capabilitiesDir)) {
7262
+ if (!fs31.existsSync(capabilitiesDir)) {
6994
7263
  return [];
6995
7264
  }
6996
- const files = fs30.readdirSync(capabilitiesDir);
7265
+ const files = fs31.readdirSync(capabilitiesDir);
6997
7266
  const capabilities = [];
6998
7267
  for (const file of files) {
6999
7268
  if (file === "capabilities.json" || !file.endsWith(".json")) {
7000
7269
  continue;
7001
7270
  }
7002
7271
  try {
7003
- const filePath = path27.join(capabilitiesDir, file);
7004
- const content = fs30.readFileSync(filePath, "utf-8");
7272
+ const filePath = path28.join(capabilitiesDir, file);
7273
+ const content = fs31.readFileSync(filePath, "utf-8");
7005
7274
  const capability = JSON.parse(content);
7006
7275
  if (capability.id && capability.pluginKey) {
7007
7276
  capabilities.push(capability);
@@ -7059,9 +7328,9 @@ async function migrateJsonFiles(options) {
7059
7328
  }
7060
7329
  const capabilitiesDir = getCapabilitiesDir2();
7061
7330
  for (const cap of newCapabilities) {
7062
- const filePath = path27.join(capabilitiesDir, `${cap.id}.json`);
7331
+ const filePath = path28.join(capabilitiesDir, `${cap.id}.json`);
7063
7332
  const content = JSON.stringify(cap, null, 2);
7064
- fs30.writeFileSync(filePath, content, "utf-8");
7333
+ fs31.writeFileSync(filePath, content, "utf-8");
7065
7334
  console.log(` \u2713 Created: ${cap.id}.json`);
7066
7335
  }
7067
7336
  return {
@@ -7073,11 +7342,11 @@ async function migrateJsonFiles(options) {
7073
7342
  }
7074
7343
 
7075
7344
  // src/commands/migration/versions/v001_capability/plugin-installer/detector.ts
7076
- import fs31 from "fs";
7345
+ import fs32 from "fs";
7077
7346
  function isPluginInstalled(pluginKey) {
7078
7347
  const actionPlugins = readActionPlugins();
7079
7348
  const manifestPath = getPluginManifestPath2(pluginKey);
7080
- return fs31.existsSync(manifestPath) && !!actionPlugins[pluginKey];
7349
+ return fs32.existsSync(manifestPath) && !!actionPlugins[pluginKey];
7081
7350
  }
7082
7351
  function detectPluginsToInstall(capabilities) {
7083
7352
  const pluginKeys = /* @__PURE__ */ new Set();
@@ -7153,12 +7422,12 @@ async function installPlugins(capabilities, options) {
7153
7422
  }
7154
7423
 
7155
7424
  // src/commands/migration/versions/v001_capability/code-migrator/index.ts
7156
- import path29 from "path";
7425
+ import path30 from "path";
7157
7426
  import { Project as Project3 } from "ts-morph";
7158
7427
 
7159
7428
  // src/commands/migration/versions/v001_capability/code-migrator/scanner.ts
7160
- import fs32 from "fs";
7161
- import path28 from "path";
7429
+ import fs33 from "fs";
7430
+ import path29 from "path";
7162
7431
  var EXCLUDED_DIRS = [
7163
7432
  "node_modules",
7164
7433
  "dist",
@@ -7173,9 +7442,9 @@ var EXCLUDED_PATTERNS = [
7173
7442
  /\.d\.ts$/
7174
7443
  ];
7175
7444
  function scanDirectory(dir, files = []) {
7176
- const entries = fs32.readdirSync(dir, { withFileTypes: true });
7445
+ const entries = fs33.readdirSync(dir, { withFileTypes: true });
7177
7446
  for (const entry of entries) {
7178
- const fullPath = path28.join(dir, entry.name);
7447
+ const fullPath = path29.join(dir, entry.name);
7179
7448
  if (entry.isDirectory()) {
7180
7449
  if (EXCLUDED_DIRS.includes(entry.name)) {
7181
7450
  continue;
@@ -7191,14 +7460,14 @@ function scanDirectory(dir, files = []) {
7191
7460
  return files;
7192
7461
  }
7193
7462
  function scanServerFiles() {
7194
- const serverDir = path28.join(getProjectRoot3(), "server");
7195
- if (!fs32.existsSync(serverDir)) {
7463
+ const serverDir = path29.join(getProjectRoot3(), "server");
7464
+ if (!fs33.existsSync(serverDir)) {
7196
7465
  return [];
7197
7466
  }
7198
7467
  return scanDirectory(serverDir);
7199
7468
  }
7200
7469
  function hasCapabilityImport(filePath) {
7201
- const content = fs32.readFileSync(filePath, "utf-8");
7470
+ const content = fs33.readFileSync(filePath, "utf-8");
7202
7471
  return /import\s+.*from\s+['"][^'"]*capabilities[^'"]*['"]/.test(content);
7203
7472
  }
7204
7473
  function scanFilesToMigrate() {
@@ -7575,7 +7844,7 @@ function analyzeFile(project, filePath, actionNameMap) {
7575
7844
  const callSites = analyzeCallSites(sourceFile, imports);
7576
7845
  const classInfo = analyzeClass(sourceFile);
7577
7846
  const { canMigrate, reason } = canAutoMigrate(classInfo);
7578
- const relativePath = path29.relative(getProjectRoot3(), filePath);
7847
+ const relativePath = path30.relative(getProjectRoot3(), filePath);
7579
7848
  return {
7580
7849
  filePath: relativePath,
7581
7850
  imports,
@@ -7586,7 +7855,7 @@ function analyzeFile(project, filePath, actionNameMap) {
7586
7855
  };
7587
7856
  }
7588
7857
  function migrateFile(project, analysis, dryRun) {
7589
- const absolutePath = path29.join(getProjectRoot3(), analysis.filePath);
7858
+ const absolutePath = path30.join(getProjectRoot3(), analysis.filePath);
7590
7859
  if (!analysis.canAutoMigrate) {
7591
7860
  return {
7592
7861
  filePath: analysis.filePath,
@@ -7689,17 +7958,17 @@ function getSuggestion(analysis) {
7689
7958
  }
7690
7959
 
7691
7960
  // src/commands/migration/versions/v001_capability/cleanup.ts
7692
- import fs33 from "fs";
7693
- import path30 from "path";
7961
+ import fs34 from "fs";
7962
+ import path31 from "path";
7694
7963
  function cleanupOldFiles(capabilities, dryRun) {
7695
7964
  const deletedFiles = [];
7696
7965
  const errors = [];
7697
7966
  const capabilitiesDir = getCapabilitiesDir2();
7698
- const oldJsonPath = path30.join(capabilitiesDir, "capabilities.json");
7699
- if (fs33.existsSync(oldJsonPath)) {
7967
+ const oldJsonPath = path31.join(capabilitiesDir, "capabilities.json");
7968
+ if (fs34.existsSync(oldJsonPath)) {
7700
7969
  try {
7701
7970
  if (!dryRun) {
7702
- fs33.unlinkSync(oldJsonPath);
7971
+ fs34.unlinkSync(oldJsonPath);
7703
7972
  }
7704
7973
  deletedFiles.push("capabilities.json");
7705
7974
  } catch (error) {
@@ -7707,11 +7976,11 @@ function cleanupOldFiles(capabilities, dryRun) {
7707
7976
  }
7708
7977
  }
7709
7978
  for (const cap of capabilities) {
7710
- const tsFilePath = path30.join(capabilitiesDir, `${cap.id}.ts`);
7711
- if (fs33.existsSync(tsFilePath)) {
7979
+ const tsFilePath = path31.join(capabilitiesDir, `${cap.id}.ts`);
7980
+ if (fs34.existsSync(tsFilePath)) {
7712
7981
  try {
7713
7982
  if (!dryRun) {
7714
- fs33.unlinkSync(tsFilePath);
7983
+ fs34.unlinkSync(tsFilePath);
7715
7984
  }
7716
7985
  deletedFiles.push(`${cap.id}.ts`);
7717
7986
  } catch (error) {
@@ -7727,8 +7996,8 @@ function cleanupOldFiles(capabilities, dryRun) {
7727
7996
  }
7728
7997
 
7729
7998
  // src/commands/migration/versions/v001_capability/report-generator.ts
7730
- import fs34 from "fs";
7731
- import path31 from "path";
7999
+ import fs35 from "fs";
8000
+ import path32 from "path";
7732
8001
  var REPORT_FILE = "capability-migration-report.md";
7733
8002
  function printSummary2(result) {
7734
8003
  const { jsonMigration, pluginInstallation, codeMigration, cleanup } = result;
@@ -7891,15 +8160,15 @@ async function generateReport(result) {
7891
8160
  }
7892
8161
  lines.push("");
7893
8162
  const logDir = process.env.LOG_DIR || "logs";
7894
- if (!fs34.existsSync(logDir)) {
8163
+ if (!fs35.existsSync(logDir)) {
7895
8164
  return;
7896
8165
  }
7897
- const reportDir = path31.join(logDir, "migration");
7898
- if (!fs34.existsSync(reportDir)) {
7899
- fs34.mkdirSync(reportDir, { recursive: true });
8166
+ const reportDir = path32.join(logDir, "migration");
8167
+ if (!fs35.existsSync(reportDir)) {
8168
+ fs35.mkdirSync(reportDir, { recursive: true });
7900
8169
  }
7901
- const reportPath = path31.join(reportDir, REPORT_FILE);
7902
- fs34.writeFileSync(reportPath, lines.join("\n"), "utf-8");
8170
+ const reportPath = path32.join(reportDir, REPORT_FILE);
8171
+ fs35.writeFileSync(reportPath, lines.join("\n"), "utf-8");
7903
8172
  console.log(`\u{1F4C4} Report generated: ${reportPath}`);
7904
8173
  }
7905
8174
 
@@ -8431,10 +8700,10 @@ var migrationCommand = {
8431
8700
  };
8432
8701
 
8433
8702
  // src/commands/read-logs/index.ts
8434
- import path32 from "path";
8703
+ import path33 from "path";
8435
8704
 
8436
8705
  // src/commands/read-logs/std-utils.ts
8437
- import fs35 from "fs";
8706
+ import fs36 from "fs";
8438
8707
  function formatStdPrefixTime(localTime) {
8439
8708
  const match = localTime.match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/);
8440
8709
  if (!match) return localTime;
@@ -8464,11 +8733,11 @@ function stripPrefixFromStdLine(line) {
8464
8733
  return `[${time}] ${content}`;
8465
8734
  }
8466
8735
  function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarker) {
8467
- const stat = fs35.statSync(filePath);
8736
+ const stat = fs36.statSync(filePath);
8468
8737
  if (stat.size === 0) {
8469
8738
  return { lines: [], markerFound: false, totalLinesCount: 0 };
8470
8739
  }
8471
- const fd = fs35.openSync(filePath, "r");
8740
+ const fd = fs36.openSync(filePath, "r");
8472
8741
  const chunkSize = 64 * 1024;
8473
8742
  let position = stat.size;
8474
8743
  let remainder = "";
@@ -8482,7 +8751,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
8482
8751
  const length = Math.min(chunkSize, position);
8483
8752
  position -= length;
8484
8753
  const buffer = Buffer.alloc(length);
8485
- fs35.readSync(fd, buffer, 0, length, position);
8754
+ fs36.readSync(fd, buffer, 0, length, position);
8486
8755
  let chunk = buffer.toString("utf8");
8487
8756
  if (remainder) {
8488
8757
  chunk += remainder;
@@ -8524,7 +8793,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
8524
8793
  }
8525
8794
  }
8526
8795
  } finally {
8527
- fs35.closeSync(fd);
8796
+ fs36.closeSync(fd);
8528
8797
  }
8529
8798
  return { lines: collected.reverse(), markerFound, totalLinesCount };
8530
8799
  }
@@ -8545,21 +8814,21 @@ function readServerStdSegment(filePath, maxLines, offset) {
8545
8814
  }
8546
8815
 
8547
8816
  // src/commands/read-logs/tail.ts
8548
- import fs36 from "fs";
8817
+ import fs37 from "fs";
8549
8818
  function fileExists(filePath) {
8550
8819
  try {
8551
- fs36.accessSync(filePath, fs36.constants.F_OK | fs36.constants.R_OK);
8820
+ fs37.accessSync(filePath, fs37.constants.F_OK | fs37.constants.R_OK);
8552
8821
  return true;
8553
8822
  } catch {
8554
8823
  return false;
8555
8824
  }
8556
8825
  }
8557
8826
  function readFileTailLines(filePath, maxLines) {
8558
- const stat = fs36.statSync(filePath);
8827
+ const stat = fs37.statSync(filePath);
8559
8828
  if (stat.size === 0) {
8560
8829
  return [];
8561
8830
  }
8562
- const fd = fs36.openSync(filePath, "r");
8831
+ const fd = fs37.openSync(filePath, "r");
8563
8832
  const chunkSize = 64 * 1024;
8564
8833
  const chunks = [];
8565
8834
  let position = stat.size;
@@ -8569,13 +8838,13 @@ function readFileTailLines(filePath, maxLines) {
8569
8838
  const length = Math.min(chunkSize, position);
8570
8839
  position -= length;
8571
8840
  const buffer = Buffer.alloc(length);
8572
- fs36.readSync(fd, buffer, 0, length, position);
8841
+ fs37.readSync(fd, buffer, 0, length, position);
8573
8842
  chunks.unshift(buffer.toString("utf8"));
8574
8843
  const chunkLines = buffer.toString("utf8").split("\n").length - 1;
8575
8844
  collectedLines += chunkLines;
8576
8845
  }
8577
8846
  } finally {
8578
- fs36.closeSync(fd);
8847
+ fs37.closeSync(fd);
8579
8848
  }
8580
8849
  const content = chunks.join("");
8581
8850
  const allLines = content.split("\n");
@@ -8591,11 +8860,11 @@ function readFileTailLines(filePath, maxLines) {
8591
8860
  return allLines.slice(allLines.length - maxLines);
8592
8861
  }
8593
8862
  function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
8594
- const stat = fs36.statSync(filePath);
8863
+ const stat = fs37.statSync(filePath);
8595
8864
  if (stat.size === 0) {
8596
8865
  return { lines: [], totalLinesCount: 0 };
8597
8866
  }
8598
- const fd = fs36.openSync(filePath, "r");
8867
+ const fd = fs37.openSync(filePath, "r");
8599
8868
  const chunkSize = 64 * 1024;
8600
8869
  let position = stat.size;
8601
8870
  let remainder = "";
@@ -8607,7 +8876,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
8607
8876
  const length = Math.min(chunkSize, position);
8608
8877
  position -= length;
8609
8878
  const buffer = Buffer.alloc(length);
8610
- fs36.readSync(fd, buffer, 0, length, position);
8879
+ fs37.readSync(fd, buffer, 0, length, position);
8611
8880
  let chunk = buffer.toString("utf8");
8612
8881
  if (remainder) {
8613
8882
  chunk += remainder;
@@ -8638,7 +8907,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
8638
8907
  }
8639
8908
  }
8640
8909
  } finally {
8641
- fs36.closeSync(fd);
8910
+ fs37.closeSync(fd);
8642
8911
  }
8643
8912
  return { lines: collected.reverse(), totalLinesCount };
8644
8913
  }
@@ -8780,7 +9049,7 @@ function readDevStdSegment(filePath, maxLines, offset) {
8780
9049
  }
8781
9050
 
8782
9051
  // src/commands/read-logs/json-lines.ts
8783
- import fs37 from "fs";
9052
+ import fs38 from "fs";
8784
9053
 
8785
9054
  // src/commands/read-logs/structured-log.ts
8786
9055
  function normalizeLevelName(value) {
@@ -8856,11 +9125,11 @@ function buildWantedLevelSet(levels) {
8856
9125
  return set.size > 0 ? set : null;
8857
9126
  }
8858
9127
  function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
8859
- const stat = fs37.statSync(filePath);
9128
+ const stat = fs38.statSync(filePath);
8860
9129
  if (stat.size === 0) {
8861
9130
  return { lines: [], totalLinesCount: 0 };
8862
9131
  }
8863
- const fd = fs37.openSync(filePath, "r");
9132
+ const fd = fs38.openSync(filePath, "r");
8864
9133
  const chunkSize = 64 * 1024;
8865
9134
  let position = stat.size;
8866
9135
  let remainder = "";
@@ -8875,7 +9144,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
8875
9144
  const length = Math.min(chunkSize, position);
8876
9145
  position -= length;
8877
9146
  const buffer = Buffer.alloc(length);
8878
- fs37.readSync(fd, buffer, 0, length, position);
9147
+ fs38.readSync(fd, buffer, 0, length, position);
8879
9148
  let chunk = buffer.toString("utf8");
8880
9149
  if (remainder) {
8881
9150
  chunk += remainder;
@@ -8937,7 +9206,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
8937
9206
  }
8938
9207
  }
8939
9208
  } finally {
8940
- fs37.closeSync(fd);
9209
+ fs38.closeSync(fd);
8941
9210
  }
8942
9211
  return { lines: collected.reverse(), totalLinesCount };
8943
9212
  }
@@ -8980,11 +9249,11 @@ function extractTraceId(obj) {
8980
9249
  function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
8981
9250
  const wanted = traceId.trim();
8982
9251
  if (!wanted) return { lines: [], totalLinesCount: 0 };
8983
- const stat = fs37.statSync(filePath);
9252
+ const stat = fs38.statSync(filePath);
8984
9253
  if (stat.size === 0) {
8985
9254
  return { lines: [], totalLinesCount: 0 };
8986
9255
  }
8987
- const fd = fs37.openSync(filePath, "r");
9256
+ const fd = fs38.openSync(filePath, "r");
8988
9257
  const chunkSize = 64 * 1024;
8989
9258
  let position = stat.size;
8990
9259
  let remainder = "";
@@ -8997,7 +9266,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
8997
9266
  const length = Math.min(chunkSize, position);
8998
9267
  position -= length;
8999
9268
  const buffer = Buffer.alloc(length);
9000
- fs37.readSync(fd, buffer, 0, length, position);
9269
+ fs38.readSync(fd, buffer, 0, length, position);
9001
9270
  let chunk = buffer.toString("utf8");
9002
9271
  if (remainder) {
9003
9272
  chunk += remainder;
@@ -9050,7 +9319,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
9050
9319
  }
9051
9320
  }
9052
9321
  } finally {
9053
- fs37.closeSync(fd);
9322
+ fs38.closeSync(fd);
9054
9323
  }
9055
9324
  return { lines: collected.reverse(), totalLinesCount };
9056
9325
  }
@@ -9059,11 +9328,11 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
9059
9328
  if (!wantedLevelSet) {
9060
9329
  return { lines: [], totalLinesCount: 0 };
9061
9330
  }
9062
- const stat = fs37.statSync(filePath);
9331
+ const stat = fs38.statSync(filePath);
9063
9332
  if (stat.size === 0) {
9064
9333
  return { lines: [], totalLinesCount: 0 };
9065
9334
  }
9066
- const fd = fs37.openSync(filePath, "r");
9335
+ const fd = fs38.openSync(filePath, "r");
9067
9336
  const chunkSize = 64 * 1024;
9068
9337
  let position = stat.size;
9069
9338
  let remainder = "";
@@ -9075,7 +9344,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
9075
9344
  const length = Math.min(chunkSize, position);
9076
9345
  position -= length;
9077
9346
  const buffer = Buffer.alloc(length);
9078
- fs37.readSync(fd, buffer, 0, length, position);
9347
+ fs38.readSync(fd, buffer, 0, length, position);
9079
9348
  let chunk = buffer.toString("utf8");
9080
9349
  if (remainder) {
9081
9350
  chunk += remainder;
@@ -9122,7 +9391,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
9122
9391
  }
9123
9392
  }
9124
9393
  } finally {
9125
- fs37.closeSync(fd);
9394
+ fs38.closeSync(fd);
9126
9395
  }
9127
9396
  return { lines: collected.reverse(), totalLinesCount };
9128
9397
  }
@@ -9615,30 +9884,30 @@ async function readLogsJsonResult(options) {
9615
9884
  };
9616
9885
  }
9617
9886
  function resolveLogFilePath(logDir, type) {
9618
- const base = path32.isAbsolute(logDir) ? logDir : path32.join(process.cwd(), logDir);
9887
+ const base = path33.isAbsolute(logDir) ? logDir : path33.join(process.cwd(), logDir);
9619
9888
  if (type === "server") {
9620
- return path32.join(base, "server.log");
9889
+ return path33.join(base, "server.log");
9621
9890
  }
9622
9891
  if (type === "trace") {
9623
- return path32.join(base, "trace.log");
9892
+ return path33.join(base, "trace.log");
9624
9893
  }
9625
9894
  if (type === "server-std") {
9626
- return path32.join(base, "server.std.log");
9895
+ return path33.join(base, "server.std.log");
9627
9896
  }
9628
9897
  if (type === "client-std") {
9629
- return path32.join(base, "client.std.log");
9898
+ return path33.join(base, "client.std.log");
9630
9899
  }
9631
9900
  if (type === "dev") {
9632
- return path32.join(base, "dev.log");
9901
+ return path33.join(base, "dev.log");
9633
9902
  }
9634
9903
  if (type === "dev-std") {
9635
- return path32.join(base, "dev.std.log");
9904
+ return path33.join(base, "dev.std.log");
9636
9905
  }
9637
9906
  if (type === "install-dep-std") {
9638
- return path32.join(base, "install-dep.std.log");
9907
+ return path33.join(base, "install-dep.std.log");
9639
9908
  }
9640
9909
  if (type === "browser") {
9641
- return path32.join(base, "browser.log");
9910
+ return path33.join(base, "browser.log");
9642
9911
  }
9643
9912
  throw new Error(`Unsupported log type: ${type}`);
9644
9913
  }
@@ -9808,9 +10077,9 @@ function camelToKebab(str) {
9808
10077
  }
9809
10078
 
9810
10079
  // src/commands/build/upload-static.handler.ts
9811
- import * as fs38 from "fs";
10080
+ import * as fs39 from "fs";
9812
10081
  import * as os3 from "os";
9813
- import * as path33 from "path";
10082
+ import * as path34 from "path";
9814
10083
  import { execFileSync as execFileSync2 } from "child_process";
9815
10084
  function readCredentialsFromEnv() {
9816
10085
  const uploadPrefix = process.env.STATIC_UPLOAD_PREFIX;
@@ -9834,8 +10103,8 @@ async function uploadStatic(options) {
9834
10103
  endpoint = UPLOAD_STATIC_DEFAULTS.endpoint,
9835
10104
  region = UPLOAD_STATIC_DEFAULTS.region
9836
10105
  } = options;
9837
- const resolvedStaticDir = path33.resolve(staticDir);
9838
- if (!fs38.existsSync(resolvedStaticDir)) {
10106
+ const resolvedStaticDir = path34.resolve(staticDir);
10107
+ if (!fs39.existsSync(resolvedStaticDir)) {
9839
10108
  console.error(`${LOG_PREFIX} \u76EE\u5F55\u4E0D\u5B58\u5728: ${resolvedStaticDir}\uFF0C\u8DF3\u8FC7\u4E0A\u4F20`);
9840
10109
  return;
9841
10110
  }
@@ -9868,8 +10137,8 @@ async function uploadStatic(options) {
9868
10137
  ({ AccessKeyID: accessKeyID, SecretAccessKey: secretAccessKey, SessionToken: sessionToken } = uploadCredential);
9869
10138
  }
9870
10139
  console.error(`${LOG_PREFIX} \u4E0A\u4F20\u76EE\u6807: ${uploadPrefix}`);
9871
- const confPath = path33.join(os3.tmpdir(), `.tosutilconfig-static-${process.pid}`);
9872
- fs38.writeFileSync(confPath, "");
10140
+ const confPath = path34.join(os3.tmpdir(), `.tosutilconfig-static-${process.pid}`);
10141
+ fs39.writeFileSync(confPath, "");
9873
10142
  try {
9874
10143
  console.error(`${LOG_PREFIX} \u914D\u7F6E tosutil...`);
9875
10144
  configureTosutil(resolvedTosutil, confPath, {
@@ -9883,7 +10152,7 @@ async function uploadStatic(options) {
9883
10152
  uploadToTos(resolvedTosutil, confPath, resolvedStaticDir, uploadPrefix);
9884
10153
  } finally {
9885
10154
  try {
9886
- fs38.unlinkSync(confPath);
10155
+ fs39.unlinkSync(confPath);
9887
10156
  } catch {
9888
10157
  }
9889
10158
  }
@@ -9903,8 +10172,8 @@ async function uploadStatic(options) {
9903
10172
  }
9904
10173
  }
9905
10174
  function resolveTosutilPath(tosutilPath) {
9906
- if (path33.isAbsolute(tosutilPath)) {
9907
- return fs38.existsSync(tosutilPath) ? tosutilPath : null;
10175
+ if (path34.isAbsolute(tosutilPath)) {
10176
+ return fs39.existsSync(tosutilPath) ? tosutilPath : null;
9908
10177
  }
9909
10178
  try {
9910
10179
  const resolved = execFileSync2("which", [tosutilPath], { encoding: "utf-8" }).trim();
@@ -9949,7 +10218,7 @@ async function resolveBucketId(appId) {
9949
10218
  return bucketId;
9950
10219
  }
9951
10220
  function isDirEmpty(dirPath) {
9952
- const entries = fs38.readdirSync(dirPath);
10221
+ const entries = fs39.readdirSync(dirPath);
9953
10222
  return entries.length === 0;
9954
10223
  }
9955
10224
 
@@ -10045,13 +10314,13 @@ var commands = [
10045
10314
 
10046
10315
  // src/index.ts
10047
10316
  for (const filename of [".env.local", ".env"]) {
10048
- const envPath = path34.join(process.cwd(), filename);
10049
- if (fs39.existsSync(envPath)) {
10317
+ const envPath = path35.join(process.cwd(), filename);
10318
+ if (fs40.existsSync(envPath)) {
10050
10319
  dotenvConfig({ path: envPath });
10051
10320
  }
10052
10321
  }
10053
- var __dirname = path34.dirname(fileURLToPath5(import.meta.url));
10054
- var pkg = JSON.parse(fs39.readFileSync(path34.join(__dirname, "../package.json"), "utf-8"));
10322
+ var __dirname = path35.dirname(fileURLToPath5(import.meta.url));
10323
+ var pkg = JSON.parse(fs40.readFileSync(path35.join(__dirname, "../package.json"), "utf-8"));
10055
10324
  var cli = new FullstackCLI(pkg.version);
10056
10325
  cli.useAll(commands);
10057
10326
  cli.run();