@lark-apaas/fullstack-cli 1.1.24 → 1.1.25

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 +623 -214
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // src/index.ts
2
- import fs22 from "fs";
3
- import path18 from "path";
4
- import { fileURLToPath as fileURLToPath4 } from "url";
2
+ import fs25 from "fs";
3
+ import path21 from "path";
4
+ import { fileURLToPath as fileURLToPath5 } from "url";
5
5
  import { config as dotenvConfig } from "dotenv";
6
6
 
7
7
  // src/cli.ts
@@ -2419,10 +2419,420 @@ var syncCommand = {
2419
2419
  }
2420
2420
  };
2421
2421
 
2422
- // src/commands/action-plugin/utils.ts
2422
+ // src/utils/http-client.ts
2423
+ import { HttpClient } from "@lark-apaas/http-client";
2424
+ var clientInstance = null;
2425
+ function getHttpClient() {
2426
+ if (!clientInstance) {
2427
+ clientInstance = new HttpClient({
2428
+ timeout: 3e4,
2429
+ platform: {
2430
+ enabled: true
2431
+ }
2432
+ });
2433
+ const canaryEnv = process.env.FORCE_FRAMEWORK_CLI_CANARY_ENV;
2434
+ if (canaryEnv) {
2435
+ clientInstance.interceptors.request.use((req) => {
2436
+ req.headers["x-tt-env"] = canaryEnv;
2437
+ return req;
2438
+ });
2439
+ }
2440
+ }
2441
+ return clientInstance;
2442
+ }
2443
+
2444
+ // src/utils/telemetry.ts
2445
+ async function reportEvents(events) {
2446
+ if (events.length === 0) {
2447
+ return true;
2448
+ }
2449
+ try {
2450
+ const client = getHttpClient();
2451
+ const response = await client.post("/api/v1/studio/innerapi/resource_events", { events });
2452
+ if (!response.ok) {
2453
+ console.warn(`[telemetry] Failed to report events: ${response.status} ${response.statusText}`);
2454
+ return false;
2455
+ }
2456
+ const result = await response.json();
2457
+ if (result.status_code !== "0") {
2458
+ console.warn(`[telemetry] API error: ${result.message}`);
2459
+ return false;
2460
+ }
2461
+ return true;
2462
+ } catch (error) {
2463
+ console.warn(`[telemetry] Failed to report events: ${error instanceof Error ? error.message : error}`);
2464
+ return false;
2465
+ }
2466
+ }
2467
+ async function reportInstallEvent(pluginKey, version) {
2468
+ await reportEvents([
2469
+ {
2470
+ resourceType: "plugin",
2471
+ resourceKey: pluginKey,
2472
+ eventType: "install",
2473
+ details: { version }
2474
+ }
2475
+ ]);
2476
+ }
2477
+ async function reportCreateInstanceEvent(pluginKey, version) {
2478
+ await reportEvents([
2479
+ {
2480
+ resourceType: "plugin",
2481
+ resourceKey: pluginKey,
2482
+ eventType: "create_instance",
2483
+ details: { version }
2484
+ }
2485
+ ]);
2486
+ }
2487
+
2488
+ // src/utils/git.ts
2489
+ import { execSync, spawnSync as spawnSync2 } from "child_process";
2423
2490
  import fs7 from "fs";
2424
2491
  import path5 from "path";
2425
- import { spawnSync as spawnSync2, execSync } from "child_process";
2492
+ function isGitRepository(cwd = process.cwd()) {
2493
+ try {
2494
+ const gitDir = path5.join(cwd, ".git");
2495
+ if (fs7.existsSync(gitDir)) {
2496
+ return true;
2497
+ }
2498
+ const result = spawnSync2("git", ["rev-parse", "--git-dir"], {
2499
+ cwd,
2500
+ stdio: "pipe",
2501
+ encoding: "utf-8"
2502
+ });
2503
+ return result.status === 0;
2504
+ } catch {
2505
+ return false;
2506
+ }
2507
+ }
2508
+ function getChangedFiles(cwd = process.cwd()) {
2509
+ try {
2510
+ const output = execSync("git status --porcelain", {
2511
+ cwd,
2512
+ stdio: "pipe",
2513
+ encoding: "utf-8"
2514
+ });
2515
+ return output.split("\n").filter((line) => line.trim()).map((line) => line.substring(3));
2516
+ } catch (error) {
2517
+ const message = error instanceof Error ? error.message : String(error);
2518
+ throw new Error(`Failed to get changed files: ${message}`);
2519
+ }
2520
+ }
2521
+ function gitAddUpgradeFiles(cwd = process.cwd(), filesToStage) {
2522
+ const filteredFiles = [];
2523
+ for (const filePath of filesToStage) {
2524
+ if (fs7.existsSync(path5.join(cwd, filePath))) {
2525
+ filteredFiles.push(filePath);
2526
+ continue;
2527
+ }
2528
+ const tracked = spawnSync2("git", ["ls-files", "--error-unmatch", "--", filePath], {
2529
+ cwd,
2530
+ stdio: "pipe",
2531
+ encoding: "utf-8"
2532
+ });
2533
+ if (tracked.status === 0) {
2534
+ filteredFiles.push(filePath);
2535
+ }
2536
+ }
2537
+ if (filteredFiles.length === 0) {
2538
+ return;
2539
+ }
2540
+ const result = spawnSync2("git", ["add", "--", ...filteredFiles], {
2541
+ cwd,
2542
+ stdio: "pipe",
2543
+ encoding: "utf-8"
2544
+ });
2545
+ if (result.error || result.status !== 0) {
2546
+ const errorMsg = result.stderr || result.error?.message || "Unknown error";
2547
+ throw new Error(`git add failed: ${errorMsg}`);
2548
+ }
2549
+ }
2550
+ function hasStagedChanges(cwd = process.cwd()) {
2551
+ const result = spawnSync2("git", ["diff", "--cached", "--quiet"], {
2552
+ cwd,
2553
+ stdio: "pipe",
2554
+ encoding: "utf-8"
2555
+ });
2556
+ if (result.status === 0) {
2557
+ return false;
2558
+ }
2559
+ if (result.status === 1) {
2560
+ return true;
2561
+ }
2562
+ const errorMsg = result.stderr || result.error?.message || "Unknown error";
2563
+ throw new Error(`Failed to check staged changes: ${errorMsg}`);
2564
+ }
2565
+ function gitCommit(message, cwd = process.cwd()) {
2566
+ const result = spawnSync2("git", ["commit", "-m", message], {
2567
+ cwd,
2568
+ stdio: "pipe",
2569
+ encoding: "utf-8"
2570
+ });
2571
+ if (result.error || result.status !== 0) {
2572
+ const errorMsg = result.stderr || result.error?.message || "Unknown error";
2573
+ throw new Error(`git commit failed: ${errorMsg}`);
2574
+ }
2575
+ }
2576
+ function autoCommitUpgradeChanges(version, cwd, filesToStage, commitMessage) {
2577
+ if (!isGitRepository(cwd)) {
2578
+ console.log("[fullstack-cli] \u26A0 Not a git repository, skipping auto-commit");
2579
+ return false;
2580
+ }
2581
+ const changedFiles = getChangedFiles(cwd);
2582
+ if (changedFiles.length === 0) {
2583
+ console.log("[fullstack-cli] No changes to commit");
2584
+ return false;
2585
+ }
2586
+ try {
2587
+ gitAddUpgradeFiles(cwd, filesToStage);
2588
+ if (!hasStagedChanges(cwd)) {
2589
+ console.log("[fullstack-cli] No upgrade changes to commit");
2590
+ return false;
2591
+ }
2592
+ const message = commitMessage || `chore(upgrade): auto-upgrade by fullstack-cli
2593
+
2594
+ - Sync template files
2595
+ - Cleanup package.json config
2596
+ - Upgrade @lark-apaas dependencies (if any)
2597
+
2598
+ Auto-committed by fullstack-cli v${version}`;
2599
+ gitCommit(message, cwd);
2600
+ console.log(`[fullstack-cli] \u2713 Auto-committed ${changedFiles.length} changed file(s)`);
2601
+ return true;
2602
+ } catch (error) {
2603
+ const message = error instanceof Error ? error.message : String(error);
2604
+ throw new Error(`Failed to auto-commit changes: ${message}`);
2605
+ }
2606
+ }
2607
+
2608
+ // src/utils/package-json.ts
2609
+ import fs8 from "fs";
2610
+ import path6 from "path";
2611
+ function readPackageJson(cwd = process.cwd()) {
2612
+ const pkgPath = path6.join(cwd, "package.json");
2613
+ if (!fs8.existsSync(pkgPath)) {
2614
+ throw new Error(`package.json not found at ${pkgPath}`);
2615
+ }
2616
+ const content = fs8.readFileSync(pkgPath, "utf-8");
2617
+ return JSON.parse(content);
2618
+ }
2619
+ function writePackageJson(pkg2, cwd = process.cwd()) {
2620
+ const pkgPath = path6.join(cwd, "package.json");
2621
+ const content = JSON.stringify(pkg2, null, 2) + "\n";
2622
+ fs8.writeFileSync(pkgPath, content, "utf-8");
2623
+ }
2624
+ function removeUpgradeScript(pkg2) {
2625
+ if (!pkg2.scripts?.upgrade) {
2626
+ return false;
2627
+ }
2628
+ delete pkg2.scripts.upgrade;
2629
+ return true;
2630
+ }
2631
+ function cleanDevScript(pkg2) {
2632
+ if (!pkg2.scripts?.dev) {
2633
+ return false;
2634
+ }
2635
+ const originalDev = pkg2.scripts.dev;
2636
+ const cleanedDev = originalDev.replace(/npm\s+run\s+upgrade\s*&&\s*/g, "").replace(/npm\s+run\s+upgrade\s*$/g, "").trim();
2637
+ if (cleanedDev !== originalDev) {
2638
+ pkg2.scripts.dev = cleanedDev;
2639
+ return true;
2640
+ }
2641
+ return false;
2642
+ }
2643
+ function cleanupPackageJson(cwd = process.cwd()) {
2644
+ try {
2645
+ const pkg2 = readPackageJson(cwd);
2646
+ let changed = false;
2647
+ if (removeUpgradeScript(pkg2)) {
2648
+ console.log("[fullstack-cli] \u2713 Removed scripts.upgrade");
2649
+ changed = true;
2650
+ }
2651
+ if (cleanDevScript(pkg2)) {
2652
+ console.log("[fullstack-cli] \u2713 Cleaned scripts.dev (removed npm run upgrade)");
2653
+ changed = true;
2654
+ }
2655
+ if (changed) {
2656
+ writePackageJson(pkg2, cwd);
2657
+ }
2658
+ return changed;
2659
+ } catch (error) {
2660
+ const message = error instanceof Error ? error.message : String(error);
2661
+ console.log(`[fullstack-cli] \u26A0 Could not cleanup package.json: ${message}`);
2662
+ return false;
2663
+ }
2664
+ }
2665
+
2666
+ // src/commands/upgrade/shared/utils.ts
2667
+ import path7 from "path";
2668
+ import fs9 from "fs";
2669
+ import { fileURLToPath as fileURLToPath4 } from "url";
2670
+ function getCliVersion() {
2671
+ try {
2672
+ const __filename = fileURLToPath4(import.meta.url);
2673
+ const __dirname2 = path7.dirname(__filename);
2674
+ const pkgPath = path7.resolve(__dirname2, "../../../package.json");
2675
+ const pkgContent = fs9.readFileSync(pkgPath, "utf-8");
2676
+ const pkg2 = JSON.parse(pkgContent);
2677
+ return pkg2.version || "unknown";
2678
+ } catch {
2679
+ return "unknown";
2680
+ }
2681
+ }
2682
+
2683
+ // src/commands/upgrade/get-upgrade-files.ts
2684
+ function getUpgradeFilesToStage(disableGenOpenapi = true) {
2685
+ const syncConfig2 = genSyncConfig({ disableGenOpenapi });
2686
+ const filesToStage = /* @__PURE__ */ new Set();
2687
+ syncConfig2.sync.forEach((rule) => {
2688
+ if (rule.type === "file" || rule.type === "directory") {
2689
+ filesToStage.add(rule.to);
2690
+ } else if (rule.type === "remove-line" || rule.type === "add-line") {
2691
+ filesToStage.add(rule.to);
2692
+ } else if (rule.type === "add-script") {
2693
+ filesToStage.add("package.json");
2694
+ } else if (rule.type === "delete-file" || rule.type === "delete-directory") {
2695
+ filesToStage.add(rule.to);
2696
+ }
2697
+ });
2698
+ filesToStage.add("package.json");
2699
+ filesToStage.add("package-lock.json");
2700
+ return Array.from(filesToStage);
2701
+ }
2702
+
2703
+ // src/commands/upgrade/run.handler.ts
2704
+ async function run3(options = {}) {
2705
+ const userProjectRoot = process.env.INIT_CWD || process.cwd();
2706
+ console.log("[fullstack-cli] Starting upgrade...");
2707
+ try {
2708
+ console.log("[fullstack-cli] Step 1/3: Syncing template files...");
2709
+ await run2({ disableGenOpenapi: options.disableGenOpenapi ?? true });
2710
+ console.log("[fullstack-cli] Step 2/3: Cleaning up package.json...");
2711
+ const cleaned = cleanupPackageJson(userProjectRoot);
2712
+ if (!cleaned) {
2713
+ console.log("[fullstack-cli] \u25CB No cleanup needed");
2714
+ }
2715
+ const shouldCommit = options.commit ?? true;
2716
+ if (shouldCommit) {
2717
+ console.log("[fullstack-cli] Step 3/3: Committing changes...");
2718
+ const version = getCliVersion();
2719
+ const filesToStage = getUpgradeFilesToStage(options.disableGenOpenapi ?? true);
2720
+ autoCommitUpgradeChanges(version, userProjectRoot, filesToStage);
2721
+ } else {
2722
+ console.log("[fullstack-cli] Step 3/3: Skipping commit (--no-commit flag)");
2723
+ }
2724
+ console.log("[fullstack-cli] Upgrade completed successfully \u2705");
2725
+ } catch (error) {
2726
+ const message = error instanceof Error ? error.message : String(error);
2727
+ console.error("[fullstack-cli] Failed to upgrade:", message);
2728
+ process.exit(1);
2729
+ }
2730
+ }
2731
+
2732
+ // src/commands/upgrade/deps/run.handler.ts
2733
+ import { spawnSync as spawnSync3 } from "child_process";
2734
+ function findLarkAapaasPackages(cwd, filterPackages) {
2735
+ const pkg2 = readPackageJson(cwd);
2736
+ const allPackages = /* @__PURE__ */ new Set();
2737
+ if (pkg2.dependencies) {
2738
+ Object.keys(pkg2.dependencies).forEach((name) => {
2739
+ if (name.startsWith("@lark-apaas/")) {
2740
+ allPackages.add(name);
2741
+ }
2742
+ });
2743
+ }
2744
+ if (pkg2.devDependencies) {
2745
+ Object.keys(pkg2.devDependencies).forEach((name) => {
2746
+ if (name.startsWith("@lark-apaas/")) {
2747
+ allPackages.add(name);
2748
+ }
2749
+ });
2750
+ }
2751
+ const packages = Array.from(allPackages);
2752
+ if (filterPackages) {
2753
+ const filter = new Set(filterPackages.split(",").map((p) => p.trim()));
2754
+ return packages.filter((p) => filter.has(p));
2755
+ }
2756
+ return packages;
2757
+ }
2758
+ function upgradePackages(packages, version, cwd) {
2759
+ if (version) {
2760
+ console.log(`[fullstack-cli] Upgrading to version ${version}...`);
2761
+ packages.forEach((pkg2) => {
2762
+ const target = `${pkg2}@${version}`;
2763
+ console.log(`[fullstack-cli] Installing ${target}...`);
2764
+ const result = spawnSync3("npm", ["install", target], {
2765
+ cwd,
2766
+ stdio: "inherit"
2767
+ });
2768
+ if (result.error || result.status !== 0) {
2769
+ throw new Error(`Failed to install ${target}`);
2770
+ }
2771
+ });
2772
+ } else {
2773
+ console.log("[fullstack-cli] Upgrading to latest compatible versions...");
2774
+ packages.forEach((pkg2) => {
2775
+ console.log(`[fullstack-cli] Updating ${pkg2}...`);
2776
+ const result = spawnSync3("npm", ["update", pkg2], {
2777
+ cwd,
2778
+ stdio: "inherit"
2779
+ });
2780
+ if (result.error || result.status !== 0) {
2781
+ throw new Error(`Failed to update ${pkg2}`);
2782
+ }
2783
+ });
2784
+ }
2785
+ }
2786
+ async function run4(options = {}) {
2787
+ const cwd = process.env.INIT_CWD || process.cwd();
2788
+ console.log("[fullstack-cli] Starting dependencies upgrade...");
2789
+ try {
2790
+ console.log("[fullstack-cli] Step 1/2: Scanning @lark-apaas dependencies...");
2791
+ const packages = findLarkAapaasPackages(cwd, options.packages);
2792
+ if (packages.length === 0) {
2793
+ console.log("[fullstack-cli] No @lark-apaas packages found");
2794
+ return;
2795
+ }
2796
+ console.log(`[fullstack-cli] Found ${packages.length} @lark-apaas package(s):`);
2797
+ packages.forEach((p) => console.log(` - ${p}`));
2798
+ console.log("[fullstack-cli] Step 2/2: Upgrading packages...");
2799
+ upgradePackages(packages, options.version, cwd);
2800
+ console.log(`[fullstack-cli] \u2713 Successfully upgraded ${packages.length} package(s)`);
2801
+ console.log("[fullstack-cli] Dependencies upgrade completed successfully \u2705");
2802
+ } catch (error) {
2803
+ const message = error instanceof Error ? error.message : String(error);
2804
+ console.error("[fullstack-cli] Failed to upgrade dependencies:", message);
2805
+ process.exit(1);
2806
+ }
2807
+ }
2808
+
2809
+ // src/commands/upgrade/deps/index.ts
2810
+ var depsCommand = {
2811
+ name: "deps",
2812
+ description: "Upgrade @lark-apaas dependencies",
2813
+ register(parentCommand) {
2814
+ parentCommand.command(this.name).description(this.description).option("--version <version>", "Upgrade to specific version").option("--packages <packages>", "Only upgrade specific packages (comma-separated)").action(async (options) => {
2815
+ await run4(options);
2816
+ });
2817
+ }
2818
+ };
2819
+
2820
+ // src/commands/upgrade/index.ts
2821
+ var upgradeCommand = {
2822
+ name: "upgrade",
2823
+ description: "Upgrade template files and auto-commit changes",
2824
+ register(program) {
2825
+ const upgradeCmd = program.command(this.name).description(this.description).option("--disable-gen-openapi", "Disable generating openapi.ts").option("--no-commit", "Skip auto-commit changes").action(async (options) => {
2826
+ await run3(options);
2827
+ });
2828
+ depsCommand.register(upgradeCmd);
2829
+ }
2830
+ };
2831
+
2832
+ // src/commands/action-plugin/utils.ts
2833
+ import fs10 from "fs";
2834
+ import path8 from "path";
2835
+ import { spawnSync as spawnSync4, execSync as execSync2 } from "child_process";
2426
2836
  function parsePluginName(input) {
2427
2837
  const match = input.match(/^(@[^/]+\/[^@]+)(?:@(.+))?$/);
2428
2838
  if (!match) {
@@ -2439,35 +2849,35 @@ function getProjectRoot() {
2439
2849
  return process.cwd();
2440
2850
  }
2441
2851
  function getPackageJsonPath() {
2442
- return path5.join(getProjectRoot(), "package.json");
2852
+ return path8.join(getProjectRoot(), "package.json");
2443
2853
  }
2444
2854
  function getPluginPath(pluginName) {
2445
- return path5.join(getProjectRoot(), "node_modules", pluginName);
2855
+ return path8.join(getProjectRoot(), "node_modules", pluginName);
2446
2856
  }
2447
- function readPackageJson() {
2857
+ function readPackageJson2() {
2448
2858
  const pkgPath = getPackageJsonPath();
2449
- if (!fs7.existsSync(pkgPath)) {
2859
+ if (!fs10.existsSync(pkgPath)) {
2450
2860
  throw new Error("package.json not found in current directory");
2451
2861
  }
2452
2862
  try {
2453
- const content = fs7.readFileSync(pkgPath, "utf-8");
2863
+ const content = fs10.readFileSync(pkgPath, "utf-8");
2454
2864
  return JSON.parse(content);
2455
2865
  } catch {
2456
2866
  throw new Error("Failed to parse package.json");
2457
2867
  }
2458
2868
  }
2459
- function writePackageJson(pkg2) {
2869
+ function writePackageJson2(pkg2) {
2460
2870
  const pkgPath = getPackageJsonPath();
2461
- fs7.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
2871
+ fs10.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
2462
2872
  }
2463
2873
  function readActionPlugins() {
2464
- const pkg2 = readPackageJson();
2874
+ const pkg2 = readPackageJson2();
2465
2875
  return pkg2.actionPlugins || {};
2466
2876
  }
2467
2877
  function writeActionPlugins(plugins) {
2468
- const pkg2 = readPackageJson();
2878
+ const pkg2 = readPackageJson2();
2469
2879
  pkg2.actionPlugins = plugins;
2470
- writePackageJson(pkg2);
2880
+ writePackageJson2(pkg2);
2471
2881
  }
2472
2882
  function isPluginInstalled(pluginName) {
2473
2883
  const plugins = readActionPlugins();
@@ -2479,7 +2889,7 @@ function getInstalledPluginVersion(pluginName) {
2479
2889
  }
2480
2890
  function npmInstall(tgzPath) {
2481
2891
  console.log(`[action-plugin] Running npm install ${tgzPath}...`);
2482
- const result = spawnSync2("npm", ["install", tgzPath, "--no-save", "--no-package-lock", "--ignore-scripts"], {
2892
+ const result = spawnSync4("npm", ["install", tgzPath, "--no-save", "--no-package-lock", "--ignore-scripts"], {
2483
2893
  cwd: getProjectRoot(),
2484
2894
  stdio: "inherit"
2485
2895
  });
@@ -2491,12 +2901,12 @@ function npmInstall(tgzPath) {
2491
2901
  }
2492
2902
  }
2493
2903
  function getPackageVersion(pluginName) {
2494
- const pkgJsonPath = path5.join(getPluginPath(pluginName), "package.json");
2495
- if (!fs7.existsSync(pkgJsonPath)) {
2904
+ const pkgJsonPath = path8.join(getPluginPath(pluginName), "package.json");
2905
+ if (!fs10.existsSync(pkgJsonPath)) {
2496
2906
  return null;
2497
2907
  }
2498
2908
  try {
2499
- const content = fs7.readFileSync(pkgJsonPath, "utf-8");
2909
+ const content = fs10.readFileSync(pkgJsonPath, "utf-8");
2500
2910
  const pkg2 = JSON.parse(content);
2501
2911
  return pkg2.version || null;
2502
2912
  } catch {
@@ -2504,49 +2914,49 @@ function getPackageVersion(pluginName) {
2504
2914
  }
2505
2915
  }
2506
2916
  function readPluginPackageJson(pluginPath) {
2507
- const pkgJsonPath = path5.join(pluginPath, "package.json");
2508
- if (!fs7.existsSync(pkgJsonPath)) {
2917
+ const pkgJsonPath = path8.join(pluginPath, "package.json");
2918
+ if (!fs10.existsSync(pkgJsonPath)) {
2509
2919
  return null;
2510
2920
  }
2511
2921
  try {
2512
- const content = fs7.readFileSync(pkgJsonPath, "utf-8");
2922
+ const content = fs10.readFileSync(pkgJsonPath, "utf-8");
2513
2923
  return JSON.parse(content);
2514
2924
  } catch {
2515
2925
  return null;
2516
2926
  }
2517
2927
  }
2518
2928
  function extractTgzToNodeModules(tgzPath, pluginName) {
2519
- const nodeModulesPath = path5.join(getProjectRoot(), "node_modules");
2520
- const targetDir = path5.join(nodeModulesPath, pluginName);
2521
- const scopeDir = path5.dirname(targetDir);
2522
- if (!fs7.existsSync(scopeDir)) {
2523
- fs7.mkdirSync(scopeDir, { recursive: true });
2929
+ const nodeModulesPath = path8.join(getProjectRoot(), "node_modules");
2930
+ const targetDir = path8.join(nodeModulesPath, pluginName);
2931
+ const scopeDir = path8.dirname(targetDir);
2932
+ if (!fs10.existsSync(scopeDir)) {
2933
+ fs10.mkdirSync(scopeDir, { recursive: true });
2524
2934
  }
2525
- if (fs7.existsSync(targetDir)) {
2526
- fs7.rmSync(targetDir, { recursive: true });
2935
+ if (fs10.existsSync(targetDir)) {
2936
+ fs10.rmSync(targetDir, { recursive: true });
2527
2937
  }
2528
- const tempDir = path5.join(nodeModulesPath, ".cache", "fullstack-cli", "extract-temp");
2529
- if (fs7.existsSync(tempDir)) {
2530
- fs7.rmSync(tempDir, { recursive: true });
2938
+ const tempDir = path8.join(nodeModulesPath, ".cache", "fullstack-cli", "extract-temp");
2939
+ if (fs10.existsSync(tempDir)) {
2940
+ fs10.rmSync(tempDir, { recursive: true });
2531
2941
  }
2532
- fs7.mkdirSync(tempDir, { recursive: true });
2942
+ fs10.mkdirSync(tempDir, { recursive: true });
2533
2943
  try {
2534
- execSync(`tar -xzf "${tgzPath}" -C "${tempDir}"`, { stdio: "pipe" });
2535
- const extractedDir = path5.join(tempDir, "package");
2536
- if (fs7.existsSync(extractedDir)) {
2537
- fs7.renameSync(extractedDir, targetDir);
2944
+ execSync2(`tar -xzf "${tgzPath}" -C "${tempDir}"`, { stdio: "pipe" });
2945
+ const extractedDir = path8.join(tempDir, "package");
2946
+ if (fs10.existsSync(extractedDir)) {
2947
+ fs10.renameSync(extractedDir, targetDir);
2538
2948
  } else {
2539
- const files = fs7.readdirSync(tempDir);
2949
+ const files = fs10.readdirSync(tempDir);
2540
2950
  if (files.length === 1) {
2541
- fs7.renameSync(path5.join(tempDir, files[0]), targetDir);
2951
+ fs10.renameSync(path8.join(tempDir, files[0]), targetDir);
2542
2952
  } else {
2543
2953
  throw new Error("Unexpected tgz structure");
2544
2954
  }
2545
2955
  }
2546
2956
  return targetDir;
2547
2957
  } finally {
2548
- if (fs7.existsSync(tempDir)) {
2549
- fs7.rmSync(tempDir, { recursive: true });
2958
+ if (fs10.existsSync(tempDir)) {
2959
+ fs10.rmSync(tempDir, { recursive: true });
2550
2960
  }
2551
2961
  }
2552
2962
  }
@@ -2555,10 +2965,10 @@ function checkMissingPeerDeps(peerDeps) {
2555
2965
  return [];
2556
2966
  }
2557
2967
  const missing = [];
2558
- const nodeModulesPath = path5.join(getProjectRoot(), "node_modules");
2968
+ const nodeModulesPath = path8.join(getProjectRoot(), "node_modules");
2559
2969
  for (const [depName, _version] of Object.entries(peerDeps)) {
2560
- const depPath = path5.join(nodeModulesPath, depName);
2561
- if (!fs7.existsSync(depPath)) {
2970
+ const depPath = path8.join(nodeModulesPath, depName);
2971
+ if (!fs10.existsSync(depPath)) {
2562
2972
  missing.push(depName);
2563
2973
  }
2564
2974
  }
@@ -2569,7 +2979,7 @@ function installMissingDeps(deps) {
2569
2979
  return;
2570
2980
  }
2571
2981
  console.log(`[action-plugin] Installing missing dependencies: ${deps.join(", ")}`);
2572
- const result = spawnSync2("npm", ["install", ...deps, "--no-save", "--no-package-lock"], {
2982
+ const result = spawnSync4("npm", ["install", ...deps, "--no-save", "--no-package-lock"], {
2573
2983
  cwd: getProjectRoot(),
2574
2984
  stdio: "inherit"
2575
2985
  });
@@ -2582,40 +2992,16 @@ function installMissingDeps(deps) {
2582
2992
  }
2583
2993
  function removePluginDirectory(pluginName) {
2584
2994
  const pluginPath = getPluginPath(pluginName);
2585
- if (fs7.existsSync(pluginPath)) {
2586
- fs7.rmSync(pluginPath, { recursive: true });
2995
+ if (fs10.existsSync(pluginPath)) {
2996
+ fs10.rmSync(pluginPath, { recursive: true });
2587
2997
  console.log(`[action-plugin] Removed ${pluginName}`);
2588
2998
  }
2589
2999
  }
2590
3000
 
2591
3001
  // src/commands/action-plugin/api-client.ts
2592
3002
  import { HttpClient as HttpClient2 } from "@lark-apaas/http-client";
2593
- import fs8 from "fs";
2594
- import path6 from "path";
2595
-
2596
- // src/utils/http-client.ts
2597
- import { HttpClient } from "@lark-apaas/http-client";
2598
- var clientInstance = null;
2599
- function getHttpClient() {
2600
- if (!clientInstance) {
2601
- clientInstance = new HttpClient({
2602
- timeout: 3e4,
2603
- platform: {
2604
- enabled: true
2605
- }
2606
- });
2607
- const canaryEnv = process.env.FORCE_FRAMEWORK_CLI_CANARY_ENV;
2608
- if (canaryEnv) {
2609
- clientInstance.interceptors.request.use((req) => {
2610
- req.headers["x-tt-env"] = canaryEnv;
2611
- return req;
2612
- });
2613
- }
2614
- }
2615
- return clientInstance;
2616
- }
2617
-
2618
- // src/commands/action-plugin/api-client.ts
3003
+ import fs11 from "fs";
3004
+ import path9 from "path";
2619
3005
  var PLUGIN_CACHE_DIR = "node_modules/.cache/fullstack-cli/plugins";
2620
3006
  async function getPluginVersions(keys, latestOnly = true) {
2621
3007
  const client = getHttpClient();
@@ -2679,19 +3065,19 @@ async function downloadFromPublic(downloadURL) {
2679
3065
  return Buffer.from(arrayBuffer);
2680
3066
  }
2681
3067
  function getPluginCacheDir() {
2682
- return path6.join(process.cwd(), PLUGIN_CACHE_DIR);
3068
+ return path9.join(process.cwd(), PLUGIN_CACHE_DIR);
2683
3069
  }
2684
3070
  function ensureCacheDir() {
2685
3071
  const cacheDir = getPluginCacheDir();
2686
- if (!fs8.existsSync(cacheDir)) {
2687
- fs8.mkdirSync(cacheDir, { recursive: true });
3072
+ if (!fs11.existsSync(cacheDir)) {
3073
+ fs11.mkdirSync(cacheDir, { recursive: true });
2688
3074
  }
2689
3075
  }
2690
3076
  function getTempFilePath(pluginKey, version) {
2691
3077
  ensureCacheDir();
2692
3078
  const safeKey = pluginKey.replace(/[/@]/g, "_");
2693
3079
  const filename = `${safeKey}@${version}.tgz`;
2694
- return path6.join(getPluginCacheDir(), filename);
3080
+ return path9.join(getPluginCacheDir(), filename);
2695
3081
  }
2696
3082
  var MAX_RETRIES = 2;
2697
3083
  async function withRetry(operation, description, maxRetries = MAX_RETRIES) {
@@ -2728,7 +3114,7 @@ async function downloadPlugin(pluginKey, requestedVersion) {
2728
3114
  );
2729
3115
  }
2730
3116
  const tgzPath = getTempFilePath(pluginKey, pluginInfo.version);
2731
- fs8.writeFileSync(tgzPath, tgzBuffer);
3117
+ fs11.writeFileSync(tgzPath, tgzBuffer);
2732
3118
  console.log(`[action-plugin] Downloaded to ${tgzPath} (${(tgzBuffer.length / 1024).toFixed(2)} KB)`);
2733
3119
  return {
2734
3120
  tgzPath,
@@ -2742,18 +3128,18 @@ function getCachePath(pluginKey, version) {
2742
3128
  ensureCacheDir();
2743
3129
  const safeKey = pluginKey.replace(/[/@]/g, "_");
2744
3130
  const filename = `${safeKey}@${version}.tgz`;
2745
- return path6.join(getPluginCacheDir(), filename);
3131
+ return path9.join(getPluginCacheDir(), filename);
2746
3132
  }
2747
3133
  function hasCachedPlugin(pluginKey, version) {
2748
3134
  const cachePath = getCachePath(pluginKey, version);
2749
- return fs8.existsSync(cachePath);
3135
+ return fs11.existsSync(cachePath);
2750
3136
  }
2751
3137
  function listCachedPlugins() {
2752
3138
  const cacheDir = getPluginCacheDir();
2753
- if (!fs8.existsSync(cacheDir)) {
3139
+ if (!fs11.existsSync(cacheDir)) {
2754
3140
  return [];
2755
3141
  }
2756
- const files = fs8.readdirSync(cacheDir);
3142
+ const files = fs11.readdirSync(cacheDir);
2757
3143
  const result = [];
2758
3144
  for (const file of files) {
2759
3145
  if (!file.endsWith(".tgz")) continue;
@@ -2761,8 +3147,8 @@ function listCachedPlugins() {
2761
3147
  if (!match) continue;
2762
3148
  const [, rawName, version] = match;
2763
3149
  const name = rawName.replace(/^_/, "@").replace(/_/, "/");
2764
- const filePath = path6.join(cacheDir, file);
2765
- const stat = fs8.statSync(filePath);
3150
+ const filePath = path9.join(cacheDir, file);
3151
+ const stat = fs11.statSync(filePath);
2766
3152
  result.push({
2767
3153
  name,
2768
3154
  version,
@@ -2775,14 +3161,14 @@ function listCachedPlugins() {
2775
3161
  }
2776
3162
  function cleanAllCache() {
2777
3163
  const cacheDir = getPluginCacheDir();
2778
- if (!fs8.existsSync(cacheDir)) {
3164
+ if (!fs11.existsSync(cacheDir)) {
2779
3165
  return 0;
2780
3166
  }
2781
- const files = fs8.readdirSync(cacheDir);
3167
+ const files = fs11.readdirSync(cacheDir);
2782
3168
  let count = 0;
2783
3169
  for (const file of files) {
2784
3170
  if (file.endsWith(".tgz")) {
2785
- fs8.unlinkSync(path6.join(cacheDir, file));
3171
+ fs11.unlinkSync(path9.join(cacheDir, file));
2786
3172
  count++;
2787
3173
  }
2788
3174
  }
@@ -2790,21 +3176,21 @@ function cleanAllCache() {
2790
3176
  }
2791
3177
  function cleanPluginCache(pluginKey, version) {
2792
3178
  const cacheDir = getPluginCacheDir();
2793
- if (!fs8.existsSync(cacheDir)) {
3179
+ if (!fs11.existsSync(cacheDir)) {
2794
3180
  return 0;
2795
3181
  }
2796
3182
  const safeKey = pluginKey.replace(/[/@]/g, "_");
2797
- const files = fs8.readdirSync(cacheDir);
3183
+ const files = fs11.readdirSync(cacheDir);
2798
3184
  let count = 0;
2799
3185
  for (const file of files) {
2800
3186
  if (version) {
2801
3187
  if (file === `${safeKey}@${version}.tgz`) {
2802
- fs8.unlinkSync(path6.join(cacheDir, file));
3188
+ fs11.unlinkSync(path9.join(cacheDir, file));
2803
3189
  count++;
2804
3190
  }
2805
3191
  } else {
2806
3192
  if (file.startsWith(`${safeKey}@`) && file.endsWith(".tgz")) {
2807
- fs8.unlinkSync(path6.join(cacheDir, file));
3193
+ fs11.unlinkSync(path9.join(cacheDir, file));
2808
3194
  count++;
2809
3195
  }
2810
3196
  }
@@ -2898,6 +3284,8 @@ async function installOne(nameWithVersion) {
2898
3284
  if (actualVersion === requestedVersion) {
2899
3285
  console.log(`[action-plugin] Plugin ${name}@${requestedVersion} is already installed`);
2900
3286
  syncActionPluginsRecord(name, actualVersion);
3287
+ reportCreateInstanceEvent(name, actualVersion).catch(() => {
3288
+ });
2901
3289
  return { name, version: actualVersion, success: true, skipped: true };
2902
3290
  }
2903
3291
  }
@@ -2908,6 +3296,8 @@ async function installOne(nameWithVersion) {
2908
3296
  if (actualVersion === targetVersion) {
2909
3297
  console.log(`[action-plugin] Plugin ${name} is already up to date (version: ${actualVersion})`);
2910
3298
  syncActionPluginsRecord(name, actualVersion);
3299
+ reportCreateInstanceEvent(name, actualVersion).catch(() => {
3300
+ });
2911
3301
  return { name, version: actualVersion, success: true, skipped: true };
2912
3302
  }
2913
3303
  console.log(`[action-plugin] Found newer version: ${targetVersion} (installed: ${actualVersion || "none"})`);
@@ -2938,6 +3328,10 @@ async function installOne(nameWithVersion) {
2938
3328
  writeActionPlugins(plugins);
2939
3329
  const source = fromCache ? "from cache" : "downloaded";
2940
3330
  console.log(`[action-plugin] Successfully installed ${name}@${installedVersion} (${source})`);
3331
+ reportInstallEvent(name, installedVersion).catch(() => {
3332
+ });
3333
+ reportCreateInstanceEvent(name, installedVersion).catch(() => {
3334
+ });
2941
3335
  return { name, version: installedVersion, success: true };
2942
3336
  } catch (error) {
2943
3337
  const message = error instanceof Error ? error.message : String(error);
@@ -3223,40 +3617,40 @@ var actionPluginCommandGroup = {
3223
3617
  };
3224
3618
 
3225
3619
  // src/commands/capability/utils.ts
3226
- import fs9 from "fs";
3620
+ import fs12 from "fs";
3227
3621
  import { createRequire as createRequire2 } from "module";
3228
- import path7 from "path";
3622
+ import path10 from "path";
3229
3623
  var CAPABILITIES_DIR = "server/capabilities";
3230
3624
  function getProjectRoot2() {
3231
3625
  return process.cwd();
3232
3626
  }
3233
3627
  function getCapabilitiesDir() {
3234
- return path7.join(getProjectRoot2(), CAPABILITIES_DIR);
3628
+ return path10.join(getProjectRoot2(), CAPABILITIES_DIR);
3235
3629
  }
3236
3630
  function getCapabilityPath(id) {
3237
- return path7.join(getCapabilitiesDir(), `${id}.json`);
3631
+ return path10.join(getCapabilitiesDir(), `${id}.json`);
3238
3632
  }
3239
3633
  function getPluginManifestPath(pluginKey) {
3240
- return path7.join(getProjectRoot2(), "node_modules", pluginKey, "manifest.json");
3634
+ return path10.join(getProjectRoot2(), "node_modules", pluginKey, "manifest.json");
3241
3635
  }
3242
3636
  function capabilitiesDirExists() {
3243
- return fs9.existsSync(getCapabilitiesDir());
3637
+ return fs12.existsSync(getCapabilitiesDir());
3244
3638
  }
3245
3639
  function listCapabilityIds() {
3246
3640
  const dir = getCapabilitiesDir();
3247
- if (!fs9.existsSync(dir)) {
3641
+ if (!fs12.existsSync(dir)) {
3248
3642
  return [];
3249
3643
  }
3250
- const files = fs9.readdirSync(dir);
3644
+ const files = fs12.readdirSync(dir);
3251
3645
  return files.filter((f) => f.endsWith(".json") && f !== "capabilities.json").map((f) => f.replace(/\.json$/, ""));
3252
3646
  }
3253
3647
  function readCapability(id) {
3254
3648
  const filePath = getCapabilityPath(id);
3255
- if (!fs9.existsSync(filePath)) {
3649
+ if (!fs12.existsSync(filePath)) {
3256
3650
  throw new Error(`Capability not found: ${id}`);
3257
3651
  }
3258
3652
  try {
3259
- const content = fs9.readFileSync(filePath, "utf-8");
3653
+ const content = fs12.readFileSync(filePath, "utf-8");
3260
3654
  return JSON.parse(content);
3261
3655
  } catch (error) {
3262
3656
  if (error instanceof SyntaxError) {
@@ -3283,11 +3677,11 @@ function readAllCapabilities() {
3283
3677
  }
3284
3678
  function readPluginManifest(pluginKey) {
3285
3679
  const manifestPath = getPluginManifestPath(pluginKey);
3286
- if (!fs9.existsSync(manifestPath)) {
3680
+ if (!fs12.existsSync(manifestPath)) {
3287
3681
  throw new Error(`Plugin not installed: ${pluginKey} (manifest.json not found)`);
3288
3682
  }
3289
3683
  try {
3290
- const content = fs9.readFileSync(manifestPath, "utf-8");
3684
+ const content = fs12.readFileSync(manifestPath, "utf-8");
3291
3685
  return JSON.parse(content);
3292
3686
  } catch (error) {
3293
3687
  if (error instanceof SyntaxError) {
@@ -3304,7 +3698,7 @@ function hasValidParamsSchema(paramsSchema) {
3304
3698
  }
3305
3699
  async function loadPlugin(pluginKey) {
3306
3700
  try {
3307
- const userRequire = createRequire2(path7.join(getProjectRoot2(), "package.json"));
3701
+ const userRequire = createRequire2(path10.join(getProjectRoot2(), "package.json"));
3308
3702
  const resolvedPath = userRequire.resolve(pluginKey);
3309
3703
  const pluginModule = await import(resolvedPath);
3310
3704
  const pluginPackage = pluginModule.default ?? pluginModule;
@@ -3463,9 +3857,12 @@ var capabilityCommandGroup = {
3463
3857
  commands: [listCommand2]
3464
3858
  };
3465
3859
 
3860
+ // src/commands/component/add.handler.ts
3861
+ import { execFile } from "child_process";
3862
+
3466
3863
  // src/commands/component/registry-preparer.ts
3467
- import fs10 from "fs";
3468
- import path8 from "path";
3864
+ import fs13 from "fs";
3865
+ import path11 from "path";
3469
3866
  import os from "os";
3470
3867
 
3471
3868
  // src/commands/component/service.ts
@@ -3521,7 +3918,7 @@ async function sendInstallEvent(key) {
3521
3918
  }
3522
3919
 
3523
3920
  // src/commands/component/registry-preparer.ts
3524
- var REGISTRY_TEMP_DIR = path8.join(os.tmpdir(), "miaoda-registry");
3921
+ var REGISTRY_TEMP_DIR = path11.join(os.tmpdir(), "miaoda-registry");
3525
3922
  function parseComponentKey(key) {
3526
3923
  const match = key.match(/^@([^/]+)\/(.+)$/);
3527
3924
  if (!match) {
@@ -3533,11 +3930,11 @@ function parseComponentKey(key) {
3533
3930
  }
3534
3931
  function getLocalRegistryPath(key) {
3535
3932
  const { scope, name } = parseComponentKey(key);
3536
- return path8.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
3933
+ return path11.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
3537
3934
  }
3538
3935
  function ensureDir(dirPath) {
3539
- if (!fs10.existsSync(dirPath)) {
3540
- fs10.mkdirSync(dirPath, { recursive: true });
3936
+ if (!fs13.existsSync(dirPath)) {
3937
+ fs13.mkdirSync(dirPath, { recursive: true });
3541
3938
  }
3542
3939
  }
3543
3940
  async function prepareRecursive(key, visited) {
@@ -3570,8 +3967,8 @@ async function prepareRecursive(key, visited) {
3570
3967
  registryDependencies: deps.map((dep) => getLocalRegistryPath(dep))
3571
3968
  };
3572
3969
  const localPath = getLocalRegistryPath(key);
3573
- ensureDir(path8.dirname(localPath));
3574
- fs10.writeFileSync(localPath, JSON.stringify(rewrittenItem, null, 2), "utf-8");
3970
+ ensureDir(path11.dirname(localPath));
3971
+ fs13.writeFileSync(localPath, JSON.stringify(rewrittenItem, null, 2), "utf-8");
3575
3972
  debug("\u4FDD\u5B58\u5230: %s", localPath);
3576
3973
  }
3577
3974
  async function prepareComponentRegistryItems(id) {
@@ -3581,18 +3978,18 @@ async function prepareComponentRegistryItems(id) {
3581
3978
  }
3582
3979
  function cleanupTempDir() {
3583
3980
  try {
3584
- if (fs10.existsSync(REGISTRY_TEMP_DIR)) {
3585
- fs10.rmSync(REGISTRY_TEMP_DIR, { recursive: true, force: true });
3981
+ if (fs13.existsSync(REGISTRY_TEMP_DIR)) {
3982
+ fs13.rmSync(REGISTRY_TEMP_DIR, { recursive: true, force: true });
3586
3983
  }
3587
3984
  } catch {
3588
3985
  }
3589
3986
  }
3590
3987
  function getDownloadedRegistryItem(itemId) {
3591
3988
  const localPath = getLocalRegistryPath(itemId);
3592
- if (!fs10.existsSync(localPath)) {
3989
+ if (!fs13.existsSync(localPath)) {
3593
3990
  return null;
3594
3991
  }
3595
- const content = fs10.readFileSync(localPath, "utf-8");
3992
+ const content = fs13.readFileSync(localPath, "utf-8");
3596
3993
  return JSON.parse(content);
3597
3994
  }
3598
3995
 
@@ -3692,6 +4089,16 @@ async function executeShadcnAdd(registryItemPath) {
3692
4089
  }
3693
4090
 
3694
4091
  // src/commands/component/add.handler.ts
4092
+ function runActionPluginInit() {
4093
+ return new Promise((resolve) => {
4094
+ execFile("fullstack-cli", ["action-plugin", "init"], { cwd: process.cwd(), stdio: "ignore" }, (error) => {
4095
+ if (error) {
4096
+ debug("action-plugin init \u5931\u8D25: %s", error.message);
4097
+ }
4098
+ resolve();
4099
+ });
4100
+ });
4101
+ }
3695
4102
  function printResult(result) {
3696
4103
  console.log(JSON.stringify(result, null, 2));
3697
4104
  }
@@ -3728,6 +4135,7 @@ async function add(key) {
3728
4135
  errors: [{ message: errorMessage }]
3729
4136
  });
3730
4137
  } finally {
4138
+ await runActionPluginInit();
3731
4139
  cleanupTempDir();
3732
4140
  }
3733
4141
  }
@@ -3749,58 +4157,58 @@ var componentCommandGroup = {
3749
4157
  };
3750
4158
 
3751
4159
  // src/commands/migration/version-manager.ts
3752
- import fs11 from "fs";
3753
- import path9 from "path";
4160
+ import fs14 from "fs";
4161
+ import path12 from "path";
3754
4162
  var PACKAGE_JSON = "package.json";
3755
4163
  var VERSION_FIELD = "migrationVersion";
3756
4164
  function getPackageJsonPath2() {
3757
- return path9.join(process.cwd(), PACKAGE_JSON);
4165
+ return path12.join(process.cwd(), PACKAGE_JSON);
3758
4166
  }
3759
4167
  function getCurrentVersion() {
3760
4168
  const pkgPath = getPackageJsonPath2();
3761
- if (!fs11.existsSync(pkgPath)) {
4169
+ if (!fs14.existsSync(pkgPath)) {
3762
4170
  throw new Error("package.json not found");
3763
4171
  }
3764
- const pkg2 = JSON.parse(fs11.readFileSync(pkgPath, "utf-8"));
4172
+ const pkg2 = JSON.parse(fs14.readFileSync(pkgPath, "utf-8"));
3765
4173
  return pkg2[VERSION_FIELD] ?? 0;
3766
4174
  }
3767
4175
  function setCurrentVersion(version) {
3768
4176
  const pkgPath = getPackageJsonPath2();
3769
- const pkg2 = JSON.parse(fs11.readFileSync(pkgPath, "utf-8"));
4177
+ const pkg2 = JSON.parse(fs14.readFileSync(pkgPath, "utf-8"));
3770
4178
  pkg2[VERSION_FIELD] = version;
3771
- fs11.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
4179
+ fs14.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
3772
4180
  }
3773
4181
 
3774
4182
  // src/commands/migration/versions/v001_capability/json-migrator/detector.ts
3775
- import fs13 from "fs";
3776
- import path11 from "path";
4183
+ import fs16 from "fs";
4184
+ import path14 from "path";
3777
4185
 
3778
4186
  // src/commands/migration/versions/v001_capability/utils.ts
3779
- import fs12 from "fs";
3780
- import path10 from "path";
4187
+ import fs15 from "fs";
4188
+ import path13 from "path";
3781
4189
  var CAPABILITIES_DIR2 = "server/capabilities";
3782
4190
  function getProjectRoot3() {
3783
4191
  return process.cwd();
3784
4192
  }
3785
4193
  function getCapabilitiesDir2() {
3786
- return path10.join(getProjectRoot3(), CAPABILITIES_DIR2);
4194
+ return path13.join(getProjectRoot3(), CAPABILITIES_DIR2);
3787
4195
  }
3788
4196
  function getPluginManifestPath2(pluginKey) {
3789
- return path10.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
4197
+ return path13.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
3790
4198
  }
3791
4199
 
3792
4200
  // src/commands/migration/versions/v001_capability/json-migrator/detector.ts
3793
4201
  function detectJsonMigration() {
3794
4202
  const capabilitiesDir = getCapabilitiesDir2();
3795
- const oldFilePath = path11.join(capabilitiesDir, "capabilities.json");
3796
- if (!fs13.existsSync(oldFilePath)) {
4203
+ const oldFilePath = path14.join(capabilitiesDir, "capabilities.json");
4204
+ if (!fs16.existsSync(oldFilePath)) {
3797
4205
  return {
3798
4206
  needsMigration: false,
3799
4207
  reason: "capabilities.json not found"
3800
4208
  };
3801
4209
  }
3802
4210
  try {
3803
- const content = fs13.readFileSync(oldFilePath, "utf-8");
4211
+ const content = fs16.readFileSync(oldFilePath, "utf-8");
3804
4212
  const parsed = JSON.parse(content);
3805
4213
  if (!Array.isArray(parsed)) {
3806
4214
  return {
@@ -3851,8 +4259,8 @@ async function check(options) {
3851
4259
  }
3852
4260
 
3853
4261
  // src/commands/migration/versions/v001_capability/json-migrator/index.ts
3854
- import fs14 from "fs";
3855
- import path12 from "path";
4262
+ import fs17 from "fs";
4263
+ import path15 from "path";
3856
4264
 
3857
4265
  // src/commands/migration/versions/v001_capability/mapping.ts
3858
4266
  var DEFAULT_PLUGIN_VERSION = "1.0.0";
@@ -4082,18 +4490,18 @@ function transformCapabilities(oldCapabilities) {
4082
4490
  // src/commands/migration/versions/v001_capability/json-migrator/index.ts
4083
4491
  function loadExistingCapabilities() {
4084
4492
  const capabilitiesDir = getCapabilitiesDir2();
4085
- if (!fs14.existsSync(capabilitiesDir)) {
4493
+ if (!fs17.existsSync(capabilitiesDir)) {
4086
4494
  return [];
4087
4495
  }
4088
- const files = fs14.readdirSync(capabilitiesDir);
4496
+ const files = fs17.readdirSync(capabilitiesDir);
4089
4497
  const capabilities = [];
4090
4498
  for (const file of files) {
4091
4499
  if (file === "capabilities.json" || !file.endsWith(".json")) {
4092
4500
  continue;
4093
4501
  }
4094
4502
  try {
4095
- const filePath = path12.join(capabilitiesDir, file);
4096
- const content = fs14.readFileSync(filePath, "utf-8");
4503
+ const filePath = path15.join(capabilitiesDir, file);
4504
+ const content = fs17.readFileSync(filePath, "utf-8");
4097
4505
  const capability = JSON.parse(content);
4098
4506
  if (capability.id && capability.pluginKey) {
4099
4507
  capabilities.push(capability);
@@ -4151,9 +4559,9 @@ async function migrateJsonFiles(options) {
4151
4559
  }
4152
4560
  const capabilitiesDir = getCapabilitiesDir2();
4153
4561
  for (const cap of newCapabilities) {
4154
- const filePath = path12.join(capabilitiesDir, `${cap.id}.json`);
4562
+ const filePath = path15.join(capabilitiesDir, `${cap.id}.json`);
4155
4563
  const content = JSON.stringify(cap, null, 2);
4156
- fs14.writeFileSync(filePath, content, "utf-8");
4564
+ fs17.writeFileSync(filePath, content, "utf-8");
4157
4565
  console.log(` \u2713 Created: ${cap.id}.json`);
4158
4566
  }
4159
4567
  return {
@@ -4165,11 +4573,11 @@ async function migrateJsonFiles(options) {
4165
4573
  }
4166
4574
 
4167
4575
  // src/commands/migration/versions/v001_capability/plugin-installer/detector.ts
4168
- import fs15 from "fs";
4576
+ import fs18 from "fs";
4169
4577
  function isPluginInstalled2(pluginKey) {
4170
4578
  const actionPlugins = readActionPlugins();
4171
4579
  const manifestPath = getPluginManifestPath2(pluginKey);
4172
- return fs15.existsSync(manifestPath) && !!actionPlugins[pluginKey];
4580
+ return fs18.existsSync(manifestPath) && !!actionPlugins[pluginKey];
4173
4581
  }
4174
4582
  function detectPluginsToInstall(capabilities) {
4175
4583
  const pluginKeys = /* @__PURE__ */ new Set();
@@ -4245,12 +4653,12 @@ async function installPlugins(capabilities, options) {
4245
4653
  }
4246
4654
 
4247
4655
  // src/commands/migration/versions/v001_capability/code-migrator/index.ts
4248
- import path14 from "path";
4656
+ import path17 from "path";
4249
4657
  import { Project as Project3 } from "ts-morph";
4250
4658
 
4251
4659
  // src/commands/migration/versions/v001_capability/code-migrator/scanner.ts
4252
- import fs16 from "fs";
4253
- import path13 from "path";
4660
+ import fs19 from "fs";
4661
+ import path16 from "path";
4254
4662
  var EXCLUDED_DIRS = [
4255
4663
  "node_modules",
4256
4664
  "dist",
@@ -4265,9 +4673,9 @@ var EXCLUDED_PATTERNS = [
4265
4673
  /\.d\.ts$/
4266
4674
  ];
4267
4675
  function scanDirectory(dir, files = []) {
4268
- const entries = fs16.readdirSync(dir, { withFileTypes: true });
4676
+ const entries = fs19.readdirSync(dir, { withFileTypes: true });
4269
4677
  for (const entry of entries) {
4270
- const fullPath = path13.join(dir, entry.name);
4678
+ const fullPath = path16.join(dir, entry.name);
4271
4679
  if (entry.isDirectory()) {
4272
4680
  if (EXCLUDED_DIRS.includes(entry.name)) {
4273
4681
  continue;
@@ -4283,14 +4691,14 @@ function scanDirectory(dir, files = []) {
4283
4691
  return files;
4284
4692
  }
4285
4693
  function scanServerFiles() {
4286
- const serverDir = path13.join(getProjectRoot3(), "server");
4287
- if (!fs16.existsSync(serverDir)) {
4694
+ const serverDir = path16.join(getProjectRoot3(), "server");
4695
+ if (!fs19.existsSync(serverDir)) {
4288
4696
  return [];
4289
4697
  }
4290
4698
  return scanDirectory(serverDir);
4291
4699
  }
4292
4700
  function hasCapabilityImport(filePath) {
4293
- const content = fs16.readFileSync(filePath, "utf-8");
4701
+ const content = fs19.readFileSync(filePath, "utf-8");
4294
4702
  return /import\s+.*from\s+['"][^'"]*capabilities[^'"]*['"]/.test(content);
4295
4703
  }
4296
4704
  function scanFilesToMigrate() {
@@ -4667,7 +5075,7 @@ function analyzeFile(project, filePath, actionNameMap) {
4667
5075
  const callSites = analyzeCallSites(sourceFile, imports);
4668
5076
  const classInfo = analyzeClass(sourceFile);
4669
5077
  const { canMigrate, reason } = canAutoMigrate(classInfo);
4670
- const relativePath = path14.relative(getProjectRoot3(), filePath);
5078
+ const relativePath = path17.relative(getProjectRoot3(), filePath);
4671
5079
  return {
4672
5080
  filePath: relativePath,
4673
5081
  imports,
@@ -4678,7 +5086,7 @@ function analyzeFile(project, filePath, actionNameMap) {
4678
5086
  };
4679
5087
  }
4680
5088
  function migrateFile(project, analysis, dryRun) {
4681
- const absolutePath = path14.join(getProjectRoot3(), analysis.filePath);
5089
+ const absolutePath = path17.join(getProjectRoot3(), analysis.filePath);
4682
5090
  if (!analysis.canAutoMigrate) {
4683
5091
  return {
4684
5092
  filePath: analysis.filePath,
@@ -4781,17 +5189,17 @@ function getSuggestion(analysis) {
4781
5189
  }
4782
5190
 
4783
5191
  // src/commands/migration/versions/v001_capability/cleanup.ts
4784
- import fs17 from "fs";
4785
- import path15 from "path";
5192
+ import fs20 from "fs";
5193
+ import path18 from "path";
4786
5194
  function cleanupOldFiles(capabilities, dryRun) {
4787
5195
  const deletedFiles = [];
4788
5196
  const errors = [];
4789
5197
  const capabilitiesDir = getCapabilitiesDir2();
4790
- const oldJsonPath = path15.join(capabilitiesDir, "capabilities.json");
4791
- if (fs17.existsSync(oldJsonPath)) {
5198
+ const oldJsonPath = path18.join(capabilitiesDir, "capabilities.json");
5199
+ if (fs20.existsSync(oldJsonPath)) {
4792
5200
  try {
4793
5201
  if (!dryRun) {
4794
- fs17.unlinkSync(oldJsonPath);
5202
+ fs20.unlinkSync(oldJsonPath);
4795
5203
  }
4796
5204
  deletedFiles.push("capabilities.json");
4797
5205
  } catch (error) {
@@ -4799,11 +5207,11 @@ function cleanupOldFiles(capabilities, dryRun) {
4799
5207
  }
4800
5208
  }
4801
5209
  for (const cap of capabilities) {
4802
- const tsFilePath = path15.join(capabilitiesDir, `${cap.id}.ts`);
4803
- if (fs17.existsSync(tsFilePath)) {
5210
+ const tsFilePath = path18.join(capabilitiesDir, `${cap.id}.ts`);
5211
+ if (fs20.existsSync(tsFilePath)) {
4804
5212
  try {
4805
5213
  if (!dryRun) {
4806
- fs17.unlinkSync(tsFilePath);
5214
+ fs20.unlinkSync(tsFilePath);
4807
5215
  }
4808
5216
  deletedFiles.push(`${cap.id}.ts`);
4809
5217
  } catch (error) {
@@ -4819,8 +5227,8 @@ function cleanupOldFiles(capabilities, dryRun) {
4819
5227
  }
4820
5228
 
4821
5229
  // src/commands/migration/versions/v001_capability/report-generator.ts
4822
- import fs18 from "fs";
4823
- import path16 from "path";
5230
+ import fs21 from "fs";
5231
+ import path19 from "path";
4824
5232
  var REPORT_FILE = "capability-migration-report.md";
4825
5233
  function printSummary(result) {
4826
5234
  const { jsonMigration, pluginInstallation, codeMigration, cleanup } = result;
@@ -4983,15 +5391,15 @@ async function generateReport(result) {
4983
5391
  }
4984
5392
  lines.push("");
4985
5393
  const logDir = process.env.LOG_DIR || "logs";
4986
- if (!fs18.existsSync(logDir)) {
5394
+ if (!fs21.existsSync(logDir)) {
4987
5395
  return;
4988
5396
  }
4989
- const reportDir = path16.join(logDir, "migration");
4990
- if (!fs18.existsSync(reportDir)) {
4991
- fs18.mkdirSync(reportDir, { recursive: true });
5397
+ const reportDir = path19.join(logDir, "migration");
5398
+ if (!fs21.existsSync(reportDir)) {
5399
+ fs21.mkdirSync(reportDir, { recursive: true });
4992
5400
  }
4993
- const reportPath = path16.join(reportDir, REPORT_FILE);
4994
- fs18.writeFileSync(reportPath, lines.join("\n"), "utf-8");
5401
+ const reportPath = path19.join(reportDir, REPORT_FILE);
5402
+ fs21.writeFileSync(reportPath, lines.join("\n"), "utf-8");
4995
5403
  console.log(`\u{1F4C4} Report generated: ${reportPath}`);
4996
5404
  }
4997
5405
 
@@ -5168,7 +5576,7 @@ function buildResult(jsonMigration, pluginInstallation, codeMigration, cleanup)
5168
5576
  }
5169
5577
 
5170
5578
  // src/commands/migration/versions/v001_capability/run.ts
5171
- async function run3(options) {
5579
+ async function run5(options) {
5172
5580
  try {
5173
5581
  const migrationOptions = {
5174
5582
  dryRun: options.dryRun ?? false
@@ -5233,7 +5641,7 @@ var v001CapabilityMigration = {
5233
5641
  name: "capability",
5234
5642
  description: "Migrate capability configurations from old format (capabilities.json array) to new format (individual JSON files)",
5235
5643
  check,
5236
- run: run3
5644
+ run: run5
5237
5645
  };
5238
5646
 
5239
5647
  // src/commands/migration/versions/index.ts
@@ -5523,10 +5931,10 @@ var migrationCommand = {
5523
5931
  };
5524
5932
 
5525
5933
  // src/commands/read-logs/index.ts
5526
- import path17 from "path";
5934
+ import path20 from "path";
5527
5935
 
5528
5936
  // src/commands/read-logs/std-utils.ts
5529
- import fs19 from "fs";
5937
+ import fs22 from "fs";
5530
5938
  function formatStdPrefixTime(localTime) {
5531
5939
  const match = localTime.match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/);
5532
5940
  if (!match) return localTime;
@@ -5556,11 +5964,11 @@ function stripPrefixFromStdLine(line) {
5556
5964
  return `[${time}] ${content}`;
5557
5965
  }
5558
5966
  function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarker) {
5559
- const stat = fs19.statSync(filePath);
5967
+ const stat = fs22.statSync(filePath);
5560
5968
  if (stat.size === 0) {
5561
5969
  return { lines: [], markerFound: false, totalLinesCount: 0 };
5562
5970
  }
5563
- const fd = fs19.openSync(filePath, "r");
5971
+ const fd = fs22.openSync(filePath, "r");
5564
5972
  const chunkSize = 64 * 1024;
5565
5973
  let position = stat.size;
5566
5974
  let remainder = "";
@@ -5574,7 +5982,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
5574
5982
  const length = Math.min(chunkSize, position);
5575
5983
  position -= length;
5576
5984
  const buffer = Buffer.alloc(length);
5577
- fs19.readSync(fd, buffer, 0, length, position);
5985
+ fs22.readSync(fd, buffer, 0, length, position);
5578
5986
  let chunk = buffer.toString("utf8");
5579
5987
  if (remainder) {
5580
5988
  chunk += remainder;
@@ -5616,7 +6024,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
5616
6024
  }
5617
6025
  }
5618
6026
  } finally {
5619
- fs19.closeSync(fd);
6027
+ fs22.closeSync(fd);
5620
6028
  }
5621
6029
  return { lines: collected.reverse(), markerFound, totalLinesCount };
5622
6030
  }
@@ -5637,21 +6045,21 @@ function readServerStdSegment(filePath, maxLines, offset) {
5637
6045
  }
5638
6046
 
5639
6047
  // src/commands/read-logs/tail.ts
5640
- import fs20 from "fs";
6048
+ import fs23 from "fs";
5641
6049
  function fileExists(filePath) {
5642
6050
  try {
5643
- fs20.accessSync(filePath, fs20.constants.F_OK | fs20.constants.R_OK);
6051
+ fs23.accessSync(filePath, fs23.constants.F_OK | fs23.constants.R_OK);
5644
6052
  return true;
5645
6053
  } catch {
5646
6054
  return false;
5647
6055
  }
5648
6056
  }
5649
6057
  function readFileTailLines(filePath, maxLines) {
5650
- const stat = fs20.statSync(filePath);
6058
+ const stat = fs23.statSync(filePath);
5651
6059
  if (stat.size === 0) {
5652
6060
  return [];
5653
6061
  }
5654
- const fd = fs20.openSync(filePath, "r");
6062
+ const fd = fs23.openSync(filePath, "r");
5655
6063
  const chunkSize = 64 * 1024;
5656
6064
  const chunks = [];
5657
6065
  let position = stat.size;
@@ -5661,13 +6069,13 @@ function readFileTailLines(filePath, maxLines) {
5661
6069
  const length = Math.min(chunkSize, position);
5662
6070
  position -= length;
5663
6071
  const buffer = Buffer.alloc(length);
5664
- fs20.readSync(fd, buffer, 0, length, position);
6072
+ fs23.readSync(fd, buffer, 0, length, position);
5665
6073
  chunks.unshift(buffer.toString("utf8"));
5666
6074
  const chunkLines = buffer.toString("utf8").split("\n").length - 1;
5667
6075
  collectedLines += chunkLines;
5668
6076
  }
5669
6077
  } finally {
5670
- fs20.closeSync(fd);
6078
+ fs23.closeSync(fd);
5671
6079
  }
5672
6080
  const content = chunks.join("");
5673
6081
  const allLines = content.split("\n");
@@ -5683,11 +6091,11 @@ function readFileTailLines(filePath, maxLines) {
5683
6091
  return allLines.slice(allLines.length - maxLines);
5684
6092
  }
5685
6093
  function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
5686
- const stat = fs20.statSync(filePath);
6094
+ const stat = fs23.statSync(filePath);
5687
6095
  if (stat.size === 0) {
5688
6096
  return { lines: [], totalLinesCount: 0 };
5689
6097
  }
5690
- const fd = fs20.openSync(filePath, "r");
6098
+ const fd = fs23.openSync(filePath, "r");
5691
6099
  const chunkSize = 64 * 1024;
5692
6100
  let position = stat.size;
5693
6101
  let remainder = "";
@@ -5699,7 +6107,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
5699
6107
  const length = Math.min(chunkSize, position);
5700
6108
  position -= length;
5701
6109
  const buffer = Buffer.alloc(length);
5702
- fs20.readSync(fd, buffer, 0, length, position);
6110
+ fs23.readSync(fd, buffer, 0, length, position);
5703
6111
  let chunk = buffer.toString("utf8");
5704
6112
  if (remainder) {
5705
6113
  chunk += remainder;
@@ -5730,7 +6138,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
5730
6138
  }
5731
6139
  }
5732
6140
  } finally {
5733
- fs20.closeSync(fd);
6141
+ fs23.closeSync(fd);
5734
6142
  }
5735
6143
  return { lines: collected.reverse(), totalLinesCount };
5736
6144
  }
@@ -5872,7 +6280,7 @@ function readDevStdSegment(filePath, maxLines, offset) {
5872
6280
  }
5873
6281
 
5874
6282
  // src/commands/read-logs/json-lines.ts
5875
- import fs21 from "fs";
6283
+ import fs24 from "fs";
5876
6284
  function normalizePid(value) {
5877
6285
  if (typeof value === "number") {
5878
6286
  return String(value);
@@ -5923,11 +6331,11 @@ function buildWantedLevelSet(levels) {
5923
6331
  return set.size > 0 ? set : null;
5924
6332
  }
5925
6333
  function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
5926
- const stat = fs21.statSync(filePath);
6334
+ const stat = fs24.statSync(filePath);
5927
6335
  if (stat.size === 0) {
5928
6336
  return { lines: [], totalLinesCount: 0 };
5929
6337
  }
5930
- const fd = fs21.openSync(filePath, "r");
6338
+ const fd = fs24.openSync(filePath, "r");
5931
6339
  const chunkSize = 64 * 1024;
5932
6340
  let position = stat.size;
5933
6341
  let remainder = "";
@@ -5942,7 +6350,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
5942
6350
  const length = Math.min(chunkSize, position);
5943
6351
  position -= length;
5944
6352
  const buffer = Buffer.alloc(length);
5945
- fs21.readSync(fd, buffer, 0, length, position);
6353
+ fs24.readSync(fd, buffer, 0, length, position);
5946
6354
  let chunk = buffer.toString("utf8");
5947
6355
  if (remainder) {
5948
6356
  chunk += remainder;
@@ -6004,7 +6412,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
6004
6412
  }
6005
6413
  }
6006
6414
  } finally {
6007
- fs21.closeSync(fd);
6415
+ fs24.closeSync(fd);
6008
6416
  }
6009
6417
  return { lines: collected.reverse(), totalLinesCount };
6010
6418
  }
@@ -6047,11 +6455,11 @@ function extractTraceId(obj) {
6047
6455
  function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
6048
6456
  const wanted = traceId.trim();
6049
6457
  if (!wanted) return { lines: [], totalLinesCount: 0 };
6050
- const stat = fs21.statSync(filePath);
6458
+ const stat = fs24.statSync(filePath);
6051
6459
  if (stat.size === 0) {
6052
6460
  return { lines: [], totalLinesCount: 0 };
6053
6461
  }
6054
- const fd = fs21.openSync(filePath, "r");
6462
+ const fd = fs24.openSync(filePath, "r");
6055
6463
  const chunkSize = 64 * 1024;
6056
6464
  let position = stat.size;
6057
6465
  let remainder = "";
@@ -6064,7 +6472,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
6064
6472
  const length = Math.min(chunkSize, position);
6065
6473
  position -= length;
6066
6474
  const buffer = Buffer.alloc(length);
6067
- fs21.readSync(fd, buffer, 0, length, position);
6475
+ fs24.readSync(fd, buffer, 0, length, position);
6068
6476
  let chunk = buffer.toString("utf8");
6069
6477
  if (remainder) {
6070
6478
  chunk += remainder;
@@ -6117,7 +6525,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
6117
6525
  }
6118
6526
  }
6119
6527
  } finally {
6120
- fs21.closeSync(fd);
6528
+ fs24.closeSync(fd);
6121
6529
  }
6122
6530
  return { lines: collected.reverse(), totalLinesCount };
6123
6531
  }
@@ -6126,11 +6534,11 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
6126
6534
  if (!wantedLevelSet) {
6127
6535
  return { lines: [], totalLinesCount: 0 };
6128
6536
  }
6129
- const stat = fs21.statSync(filePath);
6537
+ const stat = fs24.statSync(filePath);
6130
6538
  if (stat.size === 0) {
6131
6539
  return { lines: [], totalLinesCount: 0 };
6132
6540
  }
6133
- const fd = fs21.openSync(filePath, "r");
6541
+ const fd = fs24.openSync(filePath, "r");
6134
6542
  const chunkSize = 64 * 1024;
6135
6543
  let position = stat.size;
6136
6544
  let remainder = "";
@@ -6142,7 +6550,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
6142
6550
  const length = Math.min(chunkSize, position);
6143
6551
  position -= length;
6144
6552
  const buffer = Buffer.alloc(length);
6145
- fs21.readSync(fd, buffer, 0, length, position);
6553
+ fs24.readSync(fd, buffer, 0, length, position);
6146
6554
  let chunk = buffer.toString("utf8");
6147
6555
  if (remainder) {
6148
6556
  chunk += remainder;
@@ -6189,7 +6597,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
6189
6597
  }
6190
6598
  }
6191
6599
  } finally {
6192
- fs21.closeSync(fd);
6600
+ fs24.closeSync(fd);
6193
6601
  }
6194
6602
  return { lines: collected.reverse(), totalLinesCount };
6195
6603
  }
@@ -6423,34 +6831,34 @@ async function readLogsJsonResult(options) {
6423
6831
  };
6424
6832
  }
6425
6833
  function resolveLogFilePath(logDir, type) {
6426
- const base = path17.isAbsolute(logDir) ? logDir : path17.join(process.cwd(), logDir);
6834
+ const base = path20.isAbsolute(logDir) ? logDir : path20.join(process.cwd(), logDir);
6427
6835
  if (type === "server") {
6428
- return path17.join(base, "server.log");
6836
+ return path20.join(base, "server.log");
6429
6837
  }
6430
6838
  if (type === "trace") {
6431
- return path17.join(base, "trace.log");
6839
+ return path20.join(base, "trace.log");
6432
6840
  }
6433
6841
  if (type === "server-std") {
6434
- return path17.join(base, "server.std.log");
6842
+ return path20.join(base, "server.std.log");
6435
6843
  }
6436
6844
  if (type === "client-std") {
6437
- return path17.join(base, "client.std.log");
6845
+ return path20.join(base, "client.std.log");
6438
6846
  }
6439
6847
  if (type === "dev") {
6440
- return path17.join(base, "dev.log");
6848
+ return path20.join(base, "dev.log");
6441
6849
  }
6442
6850
  if (type === "dev-std") {
6443
- return path17.join(base, "dev.std.log");
6851
+ return path20.join(base, "dev.std.log");
6444
6852
  }
6445
6853
  if (type === "install-dep-std") {
6446
- return path17.join(base, "install-dep.std.log");
6854
+ return path20.join(base, "install-dep.std.log");
6447
6855
  }
6448
6856
  if (type === "browser") {
6449
- return path17.join(base, "browser.log");
6857
+ return path20.join(base, "browser.log");
6450
6858
  }
6451
6859
  throw new Error(`Unsupported log type: ${type}`);
6452
6860
  }
6453
- async function run4(options) {
6861
+ async function run6(options) {
6454
6862
  const result = await readLogsJsonResult(options);
6455
6863
  process.stdout.write(JSON.stringify(result) + "\n");
6456
6864
  }
@@ -6492,7 +6900,7 @@ var readLogsCommand = {
6492
6900
  const offset = parseNonNegativeInt(rawOptions.offset, "--offset");
6493
6901
  const traceId = typeof rawOptions.traceId === "string" ? rawOptions.traceId : void 0;
6494
6902
  const levels = parseCommaSeparatedList(rawOptions.level);
6495
- await run4({ logDir, type, maxLines, offset, traceId, levels });
6903
+ await run6({ logDir, type, maxLines, offset, traceId, levels });
6496
6904
  } catch (error) {
6497
6905
  const message = error instanceof Error ? error.message : String(error);
6498
6906
  process.stderr.write(message + "\n");
@@ -6581,6 +6989,7 @@ var buildCommandGroup = {
6581
6989
  var commands = [
6582
6990
  genDbSchemaCommand,
6583
6991
  syncCommand,
6992
+ upgradeCommand,
6584
6993
  actionPluginCommandGroup,
6585
6994
  capabilityCommandGroup,
6586
6995
  componentCommandGroup,
@@ -6590,12 +6999,12 @@ var commands = [
6590
6999
  ];
6591
7000
 
6592
7001
  // src/index.ts
6593
- var envPath = path18.join(process.cwd(), ".env");
6594
- if (fs22.existsSync(envPath)) {
7002
+ var envPath = path21.join(process.cwd(), ".env");
7003
+ if (fs25.existsSync(envPath)) {
6595
7004
  dotenvConfig({ path: envPath });
6596
7005
  }
6597
- var __dirname = path18.dirname(fileURLToPath4(import.meta.url));
6598
- var pkg = JSON.parse(fs22.readFileSync(path18.join(__dirname, "../package.json"), "utf-8"));
7006
+ var __dirname = path21.dirname(fileURLToPath5(import.meta.url));
7007
+ var pkg = JSON.parse(fs25.readFileSync(path21.join(__dirname, "../package.json"), "utf-8"));
6599
7008
  var cli = new FullstackCLI(pkg.version);
6600
7009
  cli.useAll(commands);
6601
7010
  cli.run();