@fractary/faber-cli 1.3.10 → 1.3.12
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/commands/plan/index.js +39 -10
- package/package.json +1 -1
|
@@ -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
|
|
283
|
-
if (!options.noBranch
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
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) {
|
|
@@ -328,7 +354,10 @@ async function planSingleIssue(issue, config, repoClient, anthropicClient, optio
|
|
|
328
354
|
}
|
|
329
355
|
catch (error) {
|
|
330
356
|
// If label doesn't exist, just add comment without label
|
|
331
|
-
if (error instanceof Error &&
|
|
357
|
+
if (error instanceof Error &&
|
|
358
|
+
(error.message.includes('not found') ||
|
|
359
|
+
error.message.includes('faber:planned') ||
|
|
360
|
+
error.message.includes('--add-label'))) {
|
|
332
361
|
if (outputFormat === 'text') {
|
|
333
362
|
console.log(chalk.yellow(` ⚠️ Label 'faber:planned' not found, adding comment only`));
|
|
334
363
|
}
|