episoda 0.2.29 → 0.2.31

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.
@@ -2696,7 +2696,7 @@ var require_package = __commonJS({
2696
2696
  "package.json"(exports2, module2) {
2697
2697
  module2.exports = {
2698
2698
  name: "episoda",
2699
- version: "0.2.28",
2699
+ version: "0.2.30",
2700
2700
  description: "CLI tool for Episoda local development workflow orchestration",
2701
2701
  main: "dist/index.js",
2702
2702
  types: "dist/index.d.ts",
@@ -5529,6 +5529,13 @@ var WorktreeManager = class _WorktreeManager {
5529
5529
  worktreeInfo: existing
5530
5530
  };
5531
5531
  }
5532
+ const fetchResult = await this.gitExecutor.execute({
5533
+ action: "fetch",
5534
+ remote: "origin"
5535
+ }, { cwd: this.bareRepoPath });
5536
+ if (!fetchResult.success) {
5537
+ console.warn("[worktree-manager] Failed to fetch from origin:", fetchResult.output);
5538
+ }
5532
5539
  const result = await this.gitExecutor.execute({
5533
5540
  action: "worktree_add",
5534
5541
  path: worktreePath,
@@ -7206,6 +7213,23 @@ var Daemon = class _Daemon {
7206
7213
  return;
7207
7214
  }
7208
7215
  console.log(`[Daemon] EP959: Worktree created for ${moduleUid} at ${createResult.worktreePath}`);
7216
+ if (this.deviceId) {
7217
+ try {
7218
+ const ownershipConfig = await (0, import_core10.loadConfig)();
7219
+ const ownershipApiUrl = ownershipConfig?.api_url || "https://episoda.dev";
7220
+ const ownershipResponse = await fetchWithAuth(`${ownershipApiUrl}/api/modules/${moduleUid}`, {
7221
+ method: "PATCH",
7222
+ body: JSON.stringify({ checkout_machine_id: this.deviceId })
7223
+ });
7224
+ if (ownershipResponse.ok) {
7225
+ console.log(`[Daemon] EP990: Claimed ownership of ${moduleUid} for device ${this.deviceId}`);
7226
+ } else {
7227
+ console.warn(`[Daemon] EP990: Failed to claim ownership of ${moduleUid}: ${ownershipResponse.status}`);
7228
+ }
7229
+ } catch (ownershipError) {
7230
+ console.warn(`[Daemon] EP990: Error claiming ownership of ${moduleUid}:`, ownershipError);
7231
+ }
7232
+ }
7209
7233
  worktree = await getWorktreeInfoForModule(moduleUid);
7210
7234
  if (!worktree || !worktree.exists) {
7211
7235
  console.error(`[Daemon] EP959: Worktree still not found after creation for ${moduleUid}`);
@@ -7569,8 +7593,26 @@ var Daemon = class _Daemon {
7569
7593
  await stopDevServer(moduleUid);
7570
7594
  console.log(`[Daemon] EP956: Dev server stopped for ${moduleUid}`);
7571
7595
  const worktree = await getWorktreeInfoForModule(moduleUid);
7572
- if (worktree?.exists) {
7573
- console.log(`[Daemon] EP956: Worktree for ${moduleUid} at ${worktree.path} is ready for cleanup`);
7596
+ if (worktree?.exists && worktree.path) {
7597
+ console.log(`[Daemon] EP994: Removing worktree for ${moduleUid} at ${worktree.path}`);
7598
+ const projectRoot = await findProjectRoot(worktree.path);
7599
+ if (projectRoot) {
7600
+ const manager = new WorktreeManager(projectRoot);
7601
+ if (await manager.initialize()) {
7602
+ const result = await manager.removeWorktree(moduleUid, true);
7603
+ if (result.success) {
7604
+ console.log(`[Daemon] EP994: Successfully removed worktree for ${moduleUid}`);
7605
+ } else {
7606
+ console.warn(`[Daemon] EP994: Could not remove worktree for ${moduleUid}: ${result.error}`);
7607
+ }
7608
+ } else {
7609
+ console.warn(`[Daemon] EP994: Could not initialize WorktreeManager for ${moduleUid}`);
7610
+ }
7611
+ } else {
7612
+ console.warn(`[Daemon] EP994: Could not find project root for ${moduleUid} worktree`);
7613
+ }
7614
+ } else {
7615
+ console.log(`[Daemon] EP994: No worktree to remove for ${moduleUid}`);
7574
7616
  }
7575
7617
  console.log(`[Daemon] EP956: Async cleanup complete for ${moduleUid}`);
7576
7618
  } catch (error) {
@@ -7707,7 +7749,7 @@ var Daemon = class _Daemon {
7707
7749
  }
7708
7750
  const apiUrl = config.api_url || "https://episoda.dev";
7709
7751
  const response = await fetchWithAuth(
7710
- `${apiUrl}/api/modules?state=ready,doing,review&fields=id,uid,dev_mode,tunnel_url,checkout_machine_id`
7752
+ `${apiUrl}/api/modules?state=doing,review&fields=id,uid,dev_mode,tunnel_url,checkout_machine_id`
7711
7753
  );
7712
7754
  if (!response.ok) {
7713
7755
  console.warn(`[Daemon] EP819: Failed to fetch modules: ${response.status}`);