episoda 0.2.106 → 0.2.108

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.
package/dist/index.js CHANGED
@@ -1626,12 +1626,14 @@ var require_git_executor = __commonJS({
1626
1626
  */
1627
1627
  async executeWorktreeAdd(command, cwd, options) {
1628
1628
  try {
1629
- const validation = (0, git_validator_1.validateBranchName)(command.branch);
1630
- if (!validation.valid) {
1631
- return {
1632
- success: false,
1633
- error: validation.error || "UNKNOWN_ERROR"
1634
- };
1629
+ if (!command.detach && command.branch) {
1630
+ const validation = (0, git_validator_1.validateBranchName)(command.branch);
1631
+ if (!validation.valid) {
1632
+ return {
1633
+ success: false,
1634
+ error: validation.error || "UNKNOWN_ERROR"
1635
+ };
1636
+ }
1635
1637
  }
1636
1638
  const fs14 = await Promise.resolve().then(() => __importStar(require("fs"))).then((m) => m.promises);
1637
1639
  try {
@@ -1648,7 +1650,14 @@ var require_git_executor = __commonJS({
1648
1650
  } catch {
1649
1651
  }
1650
1652
  const args = ["worktree", "add"];
1651
- if (command.create) {
1653
+ if (command.detach) {
1654
+ args.push("--detach", command.path);
1655
+ if (command.startPoint) {
1656
+ args.push(command.startPoint);
1657
+ } else {
1658
+ args.push("HEAD");
1659
+ }
1660
+ } else if (command.create) {
1652
1661
  args.push("-b", command.branch, command.path);
1653
1662
  if (command.startPoint) {
1654
1663
  args.push(command.startPoint);
@@ -1658,12 +1667,14 @@ var require_git_executor = __commonJS({
1658
1667
  }
1659
1668
  const result = await this.runGitCommand(args, cwd, options);
1660
1669
  if (result.success) {
1670
+ const outputMsg = command.detach ? `Created detached worktree at ${command.path} from ${command.startPoint || "HEAD"}` : `Created worktree at ${command.path} for branch ${command.branch}`;
1661
1671
  return {
1662
1672
  success: true,
1663
- output: `Created worktree at ${command.path} for branch ${command.branch}`,
1673
+ output: outputMsg,
1664
1674
  details: {
1665
1675
  worktreePath: command.path,
1666
- branchName: command.branch
1676
+ branchName: command.detach ? void 0 : command.branch,
1677
+ detached: command.detach
1667
1678
  }
1668
1679
  };
1669
1680
  }
@@ -3200,7 +3211,7 @@ var WorktreeManager = class _WorktreeManager {
3200
3211
  * Create a worktree for a module
3201
3212
  * The entire operation is locked to prevent race conditions
3202
3213
  */
3203
- async createWorktree(moduleUid, branchName, createBranch = false) {
3214
+ async createWorktree(moduleUid, branchName, createBranch = false, detachedHead = false) {
3204
3215
  if (!validateModuleUid(moduleUid)) {
3205
3216
  return {
3206
3217
  success: false,
@@ -3239,9 +3250,13 @@ var WorktreeManager = class _WorktreeManager {
3239
3250
  const result = await this.gitExecutor.execute({
3240
3251
  action: "worktree_add",
3241
3252
  path: worktreePath,
3242
- branch: branchName,
3243
- create: createBranch,
3244
- startPoint: createBranch ? "origin/main" : void 0
3253
+ branch: detachedHead ? void 0 : branchName,
3254
+ // No branch for detached HEAD
3255
+ create: detachedHead ? false : createBranch,
3256
+ // Don't create branch for detached
3257
+ detach: detachedHead,
3258
+ // EP1223: Detach flag
3259
+ startPoint: detachedHead ? "origin/main" : createBranch ? "origin/main" : void 0
3245
3260
  }, { cwd: this.bareRepoPath });
3246
3261
  if (!result.success) {
3247
3262
  return {