episoda 0.2.38 → 0.2.40

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.
@@ -1870,6 +1870,11 @@ var require_git_executor = __commonJS({
1870
1870
  { timeout: options?.timeout || 12e4 }
1871
1871
  // 2 minutes for clone
1872
1872
  );
1873
+ try {
1874
+ await execAsync2(`git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"`, { cwd: command.path, timeout: 5e3 });
1875
+ } catch (configError) {
1876
+ console.error("[git-executor] EP1014: Failed to configure fetch refspec:", configError);
1877
+ }
1873
1878
  return {
1874
1879
  success: true,
1875
1880
  output: `Cloned bare repository to ${command.path}`,
@@ -2721,7 +2726,7 @@ var require_package = __commonJS({
2721
2726
  "package.json"(exports2, module2) {
2722
2727
  module2.exports = {
2723
2728
  name: "episoda",
2724
- version: "0.2.38",
2729
+ version: "0.2.40",
2725
2730
  description: "CLI tool for Episoda local development workflow orchestration",
2726
2731
  main: "dist/index.js",
2727
2732
  types: "dist/index.d.ts",
@@ -5679,11 +5684,43 @@ var WorktreeManager = class _WorktreeManager {
5679
5684
  }
5680
5685
  try {
5681
5686
  const config = this.readConfig();
5682
- return config !== null;
5687
+ if (config === null) {
5688
+ return false;
5689
+ }
5690
+ await this.ensureFetchRefspecConfigured();
5691
+ return true;
5683
5692
  } catch {
5684
5693
  return false;
5685
5694
  }
5686
5695
  }
5696
+ /**
5697
+ * EP1014: Ensure fetch refspec is configured in bare repo
5698
+ * Older bare repos may be missing this configuration, causing stale worktrees
5699
+ */
5700
+ async ensureFetchRefspecConfigured() {
5701
+ try {
5702
+ const { execSync: execSync7 } = require("child_process");
5703
+ let fetchRefspec = null;
5704
+ try {
5705
+ fetchRefspec = execSync7("git config --get remote.origin.fetch", {
5706
+ cwd: this.bareRepoPath,
5707
+ encoding: "utf-8",
5708
+ timeout: 5e3
5709
+ }).trim();
5710
+ } catch {
5711
+ }
5712
+ if (!fetchRefspec) {
5713
+ console.log("[WorktreeManager] EP1014: Configuring missing fetch refspec for bare repo");
5714
+ execSync7('git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"', {
5715
+ cwd: this.bareRepoPath,
5716
+ timeout: 5e3
5717
+ });
5718
+ console.log("[WorktreeManager] EP1014: Fetch refspec configured successfully");
5719
+ }
5720
+ } catch (error) {
5721
+ console.warn("[WorktreeManager] EP1014: Failed to configure fetch refspec:", error);
5722
+ }
5723
+ }
5687
5724
  /**
5688
5725
  * Create a new worktree project from scratch
5689
5726
  */
@@ -5740,7 +5777,8 @@ var WorktreeManager = class _WorktreeManager {
5740
5777
  }
5741
5778
  const fetchResult = await this.gitExecutor.execute({
5742
5779
  action: "fetch",
5743
- remote: "origin"
5780
+ remote: "origin",
5781
+ branch: "+refs/heads/main:refs/remotes/origin/main"
5744
5782
  }, { cwd: this.bareRepoPath });
5745
5783
  if (!fetchResult.success && createBranch) {
5746
5784
  console.error("[worktree-manager] Failed to fetch from origin:", fetchResult.output);
@@ -6854,10 +6892,17 @@ var Daemon = class _Daemon {
6854
6892
  serverUrl = config.project_settings.local_server_url;
6855
6893
  console.log(`[Daemon] Using cached server URL: ${serverUrl}`);
6856
6894
  }
6857
- const serverUrlObj = new URL(serverUrl);
6858
- const wsProtocol = serverUrlObj.protocol === "https:" ? "wss:" : "ws:";
6859
- const wsPort = process.env.EPISODA_WS_PORT || "3001";
6860
- const wsUrl = `${wsProtocol}//${serverUrlObj.hostname}:${wsPort}`;
6895
+ let wsUrl;
6896
+ if (config.ws_url) {
6897
+ wsUrl = config.ws_url;
6898
+ console.log(`[Daemon] Using configured ws_url: ${wsUrl}`);
6899
+ } else {
6900
+ const serverUrlObj = new URL(serverUrl);
6901
+ const wsProtocol = serverUrlObj.protocol === "https:" ? "wss:" : "ws:";
6902
+ const wsPort = process.env.EPISODA_WS_PORT || "3001";
6903
+ const wsHostname = serverUrlObj.hostname === "episoda.dev" ? "ws.episoda.dev" : serverUrlObj.hostname;
6904
+ wsUrl = `${wsProtocol}//${wsHostname}:${wsPort}`;
6905
+ }
6861
6906
  console.log(`[Daemon] Connecting to ${wsUrl} for project ${projectId}...`);
6862
6907
  const client = new import_core10.EpisodaClient();
6863
6908
  const gitExecutor = new import_core10.GitExecutor();