episoda 0.2.124 → 0.2.125

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.
@@ -2815,7 +2815,7 @@ var require_package = __commonJS({
2815
2815
  "package.json"(exports2, module2) {
2816
2816
  module2.exports = {
2817
2817
  name: "episoda",
2818
- version: "0.2.123",
2818
+ version: "0.2.124",
2819
2819
  description: "CLI tool for Episoda local development workflow orchestration",
2820
2820
  main: "dist/index.js",
2821
2821
  types: "dist/index.d.ts",
@@ -4210,6 +4210,7 @@ var WorktreeManager = class _WorktreeManager {
4210
4210
  };
4211
4211
  }
4212
4212
  const worktreePath = path7.join(this.projectRoot, moduleUid);
4213
+ const normalizedWorktreePath = path7.resolve(worktreePath);
4213
4214
  const lockAcquired = await this.acquireLock();
4214
4215
  if (!lockAcquired) {
4215
4216
  return {
@@ -4226,6 +4227,47 @@ var WorktreeManager = class _WorktreeManager {
4226
4227
  worktreeInfo: existing
4227
4228
  };
4228
4229
  }
4230
+ if (fs6.existsSync(worktreePath)) {
4231
+ const listResult = await this.gitExecutor.execute({
4232
+ action: "worktree_list"
4233
+ }, { cwd: this.bareRepoPath });
4234
+ const worktrees = listResult.details?.worktrees || [];
4235
+ const matching = worktrees.find((w) => path7.resolve(w.path) === normalizedWorktreePath);
4236
+ if (matching) {
4237
+ const adoptedWorktree = {
4238
+ moduleUid,
4239
+ branchName: matching.branch && matching.branch !== "unknown" ? matching.branch : branchName,
4240
+ worktreePath,
4241
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
4242
+ lastAccessed: (/* @__PURE__ */ new Date()).toISOString()
4243
+ };
4244
+ const config2 = this.readConfig();
4245
+ if (config2) {
4246
+ config2.worktrees = config2.worktrees.filter((w) => w.moduleUid !== moduleUid);
4247
+ config2.worktrees.push(adoptedWorktree);
4248
+ this.writeConfig(config2);
4249
+ }
4250
+ return {
4251
+ success: true,
4252
+ worktreePath: adoptedWorktree.worktreePath,
4253
+ worktreeInfo: adoptedWorktree
4254
+ };
4255
+ }
4256
+ if (process.env.EPISODA_MODE !== "cloud") {
4257
+ return {
4258
+ success: false,
4259
+ error: `Worktree already exists at path: ${worktreePath}`
4260
+ };
4261
+ }
4262
+ console.warn(`[WorktreeManager] EP1265: Removing stale worktree path at ${worktreePath}`);
4263
+ fs6.rmSync(worktreePath, { recursive: true, force: true });
4264
+ const pruneResult = await this.gitExecutor.execute({
4265
+ action: "worktree_prune"
4266
+ }, { cwd: this.bareRepoPath });
4267
+ if (!pruneResult.success) {
4268
+ console.warn("[WorktreeManager] EP1265: Failed to prune worktrees (continuing):", pruneResult.output);
4269
+ }
4270
+ }
4229
4271
  const fetchResult = await this.gitExecutor.execute({
4230
4272
  action: "fetch",
4231
4273
  remote: "origin",