@fractary/faber-cli 1.3.10 → 1.3.11

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.
@@ -279,26 +279,52 @@ async function planSingleIssue(issue, config, repoClient, anthropicClient, optio
279
279
  issueNumber: issue.number,
280
280
  });
281
281
  const planId = plan.plan_id;
282
- // Create branch (only if not creating worktree, since worktree creation handles branch creation)
283
- if (!options.noBranch && options.noWorktree) {
282
+ // Create branch without checking it out (so it won't conflict with worktree creation)
283
+ if (!options.noBranch) {
284
284
  if (outputFormat === 'text') {
285
285
  console.log(chalk.gray(` → Creating branch: ${branch}...`));
286
286
  process.stdout.write(''); // Force flush
287
287
  }
288
- await repoClient.createBranch(branch);
288
+ // Use git branch instead of checkout to avoid switching the main repo
289
+ const { exec } = await import('child_process');
290
+ const { promisify } = await import('util');
291
+ const execAsync = promisify(exec);
292
+ try {
293
+ await execAsync(`git branch ${branch} 2>/dev/null || true`);
294
+ }
295
+ catch (error) {
296
+ // Branch might already exist, that's ok
297
+ }
289
298
  }
290
- // Create worktree (this will also create the branch automatically)
299
+ // Create worktree
291
300
  let worktreePath = worktree;
292
301
  if (!options.noWorktree) {
293
302
  if (outputFormat === 'text') {
294
303
  console.log(chalk.gray(` → Creating worktree: ${worktree}...`));
295
304
  process.stdout.write(''); // Force flush
296
305
  }
297
- const worktreeResult = await repoClient.createWorktree({
298
- workId: issue.number.toString(),
299
- path: worktree,
300
- });
301
- worktreePath = worktreeResult.absolute_path;
306
+ try {
307
+ const worktreeResult = await repoClient.createWorktree({
308
+ workId: issue.number.toString(),
309
+ path: worktree,
310
+ });
311
+ worktreePath = worktreeResult.absolute_path;
312
+ }
313
+ catch (error) {
314
+ // If worktree already exists, try to use it
315
+ if (error instanceof Error && error.message.includes('already exists')) {
316
+ if (outputFormat === 'text') {
317
+ console.log(chalk.yellow(` ⚠️ Worktree already exists, using existing worktree`));
318
+ }
319
+ const expandedPath = worktree.startsWith('~')
320
+ ? worktree.replace('~', (await import('os')).homedir())
321
+ : worktree;
322
+ worktreePath = path.resolve(expandedPath);
323
+ }
324
+ else {
325
+ throw error;
326
+ }
327
+ }
302
328
  }
303
329
  // Write plan to worktree
304
330
  if (!options.noWorktree) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fractary/faber-cli",
3
- "version": "1.3.10",
3
+ "version": "1.3.11",
4
4
  "description": "FABER CLI - Command-line interface for FABER development toolkit",
5
5
  "main": "dist/index.js",
6
6
  "bin": {