@episoda/cli 0.2.162 → 0.2.163

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.
@@ -2911,7 +2911,7 @@ var require_package = __commonJS({
2911
2911
  "package.json"(exports2, module2) {
2912
2912
  module2.exports = {
2913
2913
  name: "@episoda/cli",
2914
- version: "0.2.162",
2914
+ version: "0.2.163",
2915
2915
  description: "CLI tool for Episoda local development workflow orchestration",
2916
2916
  main: "dist/index.js",
2917
2917
  types: "dist/index.d.ts",
@@ -11763,6 +11763,18 @@ function getBuildPackagesCommand(packageManagerName) {
11763
11763
  return null;
11764
11764
  }
11765
11765
  }
11766
+ function hasPackageScript(worktreePath, scriptName) {
11767
+ try {
11768
+ const packageJsonPath = path23.join(worktreePath, "package.json");
11769
+ if (!fs22.existsSync(packageJsonPath)) {
11770
+ return false;
11771
+ }
11772
+ const packageJson2 = JSON.parse(fs22.readFileSync(packageJsonPath, "utf-8"));
11773
+ return typeof packageJson2.scripts?.[scriptName] === "string";
11774
+ } catch {
11775
+ return false;
11776
+ }
11777
+ }
11766
11778
  async function handleWorktreeCreate(request2) {
11767
11779
  const {
11768
11780
  workspaceSlug,
@@ -11855,14 +11867,13 @@ async function handleWorktreeCreate(request2) {
11855
11867
  }
11856
11868
  const isCloud = process.env.EPISODA_MODE === "cloud";
11857
11869
  let effectiveSetupScript = setupScript || await autoDetectSetupScript(worktreePath);
11858
- if (isCloud) {
11859
- const detection = detectPackageManager(worktreePath);
11860
- const buildCmd = getBuildPackagesCommand(detection.packageManager?.name);
11861
- if (buildCmd && !effectiveSetupScript?.includes("build:packages")) {
11862
- effectiveSetupScript = effectiveSetupScript ? `${effectiveSetupScript}
11870
+ const detection = detectPackageManager(worktreePath);
11871
+ const buildCmd = getBuildPackagesCommand(detection.packageManager?.name);
11872
+ const hasBuildPackages = hasPackageScript(worktreePath, "build:packages");
11873
+ if (buildCmd && hasBuildPackages && !effectiveSetupScript?.includes("build:packages")) {
11874
+ effectiveSetupScript = effectiveSetupScript ? `${effectiveSetupScript}
11863
11875
  ${buildCmd}` : buildCmd;
11864
- console.log(`[Worktree] EP1262: Added build:packages bootstrap for cloud setup`);
11865
- }
11876
+ console.log(`[Worktree] EP1386: Added build:packages bootstrap for ${isCloud ? "cloud" : "local"} setup`);
11866
11877
  }
11867
11878
  if (effectiveSetupScript) {
11868
11879
  const setupStartMs = Date.now();
@@ -11884,30 +11895,8 @@ ${buildCmd}` : buildCmd;
11884
11895
  let port;
11885
11896
  if (moduleType === "ops") {
11886
11897
  console.log(`[Worktree] EP1363: Skipping preview for ops module ${moduleUid}`);
11887
- } else if (finalStatus === "ready" && !isCloud) {
11888
- port = allocatePort(moduleUid);
11889
- console.log(`[Worktree] EP1143: Allocated port ${port} for ${moduleUid}`);
11890
- const previewManager = getPreviewManager();
11891
- const previewResult = await previewManager.startPreview({
11892
- moduleUid,
11893
- worktreePath,
11894
- port
11895
- });
11896
- if (previewResult.success) {
11897
- previewUrl = previewResult.previewUrl;
11898
- console.log(`[Worktree] EP1143: Preview started: ${previewUrl || "pending URL"}`);
11899
- } else {
11900
- finalStatus = "error";
11901
- finalError = previewResult.error || "Preview start failed";
11902
- console.error(`[Worktree] EP1143: Preview failed: ${finalError}`);
11903
- try {
11904
- await previewManager.stopPreview(moduleUid);
11905
- } catch (cleanupError) {
11906
- console.warn(`[Worktree] EP1143: Preview cleanup failed: ${cleanupError.message}`);
11907
- }
11908
- }
11909
- } else if (finalStatus === "ready" && isCloud) {
11910
- console.log(`[Worktree] EP1262: Skipping preview start in cloud mode (server orchestrates)`);
11898
+ } else if (finalStatus === "ready") {
11899
+ console.log(`[Worktree] EP1386: Skipping preview start during worktree create (deferred until module is doing)`);
11911
11900
  }
11912
11901
  console.log(`[Worktree] EP1373: worktree_create_total phase=worktree_create_total durationMs=${Date.now() - worktreeStartMs} moduleUid=${moduleUid} correlationId=${correlationId || "none"} status=${finalStatus}`);
11913
11902
  console.log(`[Worktree] EP1143: Worktree ready for ${moduleUid}`);