@episoda/cli 0.2.161 → 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.
@@ -2141,7 +2141,7 @@ var require_websocket_client = __commonJS({
2141
2141
  * @param url - WebSocket URL (wss://episoda.dev/cli)
2142
2142
  * @param token - OAuth access token
2143
2143
  * @param machineId - Optional machine identifier for multi-machine support
2144
- * @param deviceInfo - Optional device information (hostname, OS, daemonPid)
2144
+ * @param deviceInfo - Optional device information (hostname, OS, daemonPid, cliVersion)
2145
2145
  * EP1119: Added environment and containerId for cloud routing
2146
2146
  */
2147
2147
  async connect(url, token, machineId, deviceInfo) {
@@ -2152,6 +2152,7 @@ var require_websocket_client = __commonJS({
2152
2152
  this.osPlatform = deviceInfo?.osPlatform;
2153
2153
  this.osArch = deviceInfo?.osArch;
2154
2154
  this.daemonPid = deviceInfo?.daemonPid;
2155
+ this.cliVersion = deviceInfo?.cliVersion;
2155
2156
  this.environment = deviceInfo?.environment;
2156
2157
  this.containerId = deviceInfo?.containerId;
2157
2158
  this.isDisconnecting = false;
@@ -2190,7 +2191,7 @@ var require_websocket_client = __commonJS({
2190
2191
  this.send({
2191
2192
  type: "auth",
2192
2193
  token,
2193
- version: version_1.VERSION,
2194
+ version: this.cliVersion || version_1.VERSION,
2194
2195
  environment: this.environment,
2195
2196
  machineId,
2196
2197
  containerId: this.containerId,
@@ -2509,6 +2510,7 @@ var require_websocket_client = __commonJS({
2509
2510
  osPlatform: this.osPlatform,
2510
2511
  osArch: this.osArch,
2511
2512
  daemonPid: this.daemonPid,
2513
+ cliVersion: this.cliVersion,
2512
2514
  environment: this.environment,
2513
2515
  containerId: this.containerId
2514
2516
  }).then(() => {
@@ -2909,7 +2911,7 @@ var require_package = __commonJS({
2909
2911
  "package.json"(exports2, module2) {
2910
2912
  module2.exports = {
2911
2913
  name: "@episoda/cli",
2912
- version: "0.2.161",
2914
+ version: "0.2.163",
2913
2915
  description: "CLI tool for Episoda local development workflow orchestration",
2914
2916
  main: "dist/index.js",
2915
2917
  types: "dist/index.d.ts",
@@ -11761,6 +11763,18 @@ function getBuildPackagesCommand(packageManagerName) {
11761
11763
  return null;
11762
11764
  }
11763
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
+ }
11764
11778
  async function handleWorktreeCreate(request2) {
11765
11779
  const {
11766
11780
  workspaceSlug,
@@ -11853,14 +11867,13 @@ async function handleWorktreeCreate(request2) {
11853
11867
  }
11854
11868
  const isCloud = process.env.EPISODA_MODE === "cloud";
11855
11869
  let effectiveSetupScript = setupScript || await autoDetectSetupScript(worktreePath);
11856
- if (isCloud) {
11857
- const detection = detectPackageManager(worktreePath);
11858
- const buildCmd = getBuildPackagesCommand(detection.packageManager?.name);
11859
- if (buildCmd && !effectiveSetupScript?.includes("build:packages")) {
11860
- 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}
11861
11875
  ${buildCmd}` : buildCmd;
11862
- console.log(`[Worktree] EP1262: Added build:packages bootstrap for cloud setup`);
11863
- }
11876
+ console.log(`[Worktree] EP1386: Added build:packages bootstrap for ${isCloud ? "cloud" : "local"} setup`);
11864
11877
  }
11865
11878
  if (effectiveSetupScript) {
11866
11879
  const setupStartMs = Date.now();
@@ -11882,30 +11895,8 @@ ${buildCmd}` : buildCmd;
11882
11895
  let port;
11883
11896
  if (moduleType === "ops") {
11884
11897
  console.log(`[Worktree] EP1363: Skipping preview for ops module ${moduleUid}`);
11885
- } else if (finalStatus === "ready" && !isCloud) {
11886
- port = allocatePort(moduleUid);
11887
- console.log(`[Worktree] EP1143: Allocated port ${port} for ${moduleUid}`);
11888
- const previewManager = getPreviewManager();
11889
- const previewResult = await previewManager.startPreview({
11890
- moduleUid,
11891
- worktreePath,
11892
- port
11893
- });
11894
- if (previewResult.success) {
11895
- previewUrl = previewResult.previewUrl;
11896
- console.log(`[Worktree] EP1143: Preview started: ${previewUrl || "pending URL"}`);
11897
- } else {
11898
- finalStatus = "error";
11899
- finalError = previewResult.error || "Preview start failed";
11900
- console.error(`[Worktree] EP1143: Preview failed: ${finalError}`);
11901
- try {
11902
- await previewManager.stopPreview(moduleUid);
11903
- } catch (cleanupError) {
11904
- console.warn(`[Worktree] EP1143: Preview cleanup failed: ${cleanupError.message}`);
11905
- }
11906
- }
11907
- } else if (finalStatus === "ready" && isCloud) {
11908
- 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)`);
11909
11900
  }
11910
11901
  console.log(`[Worktree] EP1373: worktree_create_total phase=worktree_create_total durationMs=${Date.now() - worktreeStartMs} moduleUid=${moduleUid} correlationId=${correlationId || "none"} status=${finalStatus}`);
11911
11902
  console.log(`[Worktree] EP1143: Worktree ready for ${moduleUid}`);
@@ -15009,6 +15000,7 @@ var Daemon = class _Daemon {
15009
15000
  osPlatform: os12.platform(),
15010
15001
  osArch: os12.arch(),
15011
15002
  daemonPid,
15003
+ cliVersion: packageJson.version,
15012
15004
  environment,
15013
15005
  containerId
15014
15006
  });