@damper/cli 0.8.0 → 0.9.1

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.
@@ -274,17 +274,52 @@ export async function postTaskFlow(options) {
274
274
  console.log(pc.dim('Keeping changes local.\n'));
275
275
  }
276
276
  else if (mergeAction === 'merge') {
277
- // Merge directly to main
277
+ // Merge directly to main — first merge main into feature to resolve conflicts
278
278
  try {
279
279
  const { execa } = await import('execa');
280
- console.log(pc.dim('Switching to main and merging...'));
281
280
  // Fetch latest main
282
281
  await execa('git', ['fetch', 'origin', 'main'], { cwd, stdio: 'pipe' });
283
- // Checkout main in the main project root (not worktree)
284
- await execa('git', ['checkout', 'main'], { cwd: projectRoot, stdio: 'pipe' });
285
- // Merge the feature branch
286
- await execa('git', ['merge', currentBranch, '--no-edit'], { cwd: projectRoot, stdio: 'inherit' });
287
- console.log(pc.green(' Merged to main locally\n'));
282
+ // Step 1: Merge origin/main INTO the feature branch (in worktree)
283
+ console.log(pc.dim('Merging main into feature branch...'));
284
+ let mainMergedIntoFeature = false;
285
+ try {
286
+ await execa('git', ['merge', 'origin/main', '--no-edit'], { cwd, stdio: 'pipe' });
287
+ mainMergedIntoFeature = true;
288
+ console.log(pc.green('✓ Main merged into feature branch (no conflicts)'));
289
+ }
290
+ catch {
291
+ // Merge conflicts — launch Claude to resolve
292
+ console.log(pc.yellow('Merge conflicts detected. Launching Claude to resolve...'));
293
+ await execa('git', ['merge', '--abort'], { cwd, stdio: 'pipe' });
294
+ await launchClaudeForMerge({ cwd, apiKey });
295
+ // Verify merge was completed (origin/main should be ancestor of HEAD)
296
+ try {
297
+ await execa('git', ['merge-base', '--is-ancestor', 'origin/main', 'HEAD'], { cwd, stdio: 'pipe' });
298
+ mainMergedIntoFeature = true;
299
+ console.log(pc.green('✓ Claude resolved merge conflicts'));
300
+ }
301
+ catch {
302
+ console.log(pc.red('Claude did not complete the merge. Skipping merge to main.\n'));
303
+ }
304
+ }
305
+ // Step 2: Merge feature → main (should be clean now)
306
+ if (mainMergedIntoFeature) {
307
+ console.log(pc.dim('Merging feature into main...'));
308
+ await execa('git', ['checkout', 'main'], { cwd: projectRoot, stdio: 'pipe' });
309
+ await execa('git', ['merge', currentBranch, '--no-edit'], { cwd: projectRoot, stdio: 'inherit' });
310
+ console.log(pc.green('✓ Merged to main locally'));
311
+ const shouldPush = await confirm({
312
+ message: 'Push main to origin?',
313
+ default: false,
314
+ });
315
+ if (shouldPush) {
316
+ await execa('git', ['push', 'origin', 'main'], { cwd: projectRoot, stdio: 'inherit' });
317
+ console.log(pc.green('✓ Pushed main to origin\n'));
318
+ }
319
+ else {
320
+ console.log(pc.dim('Skipped push. Run `git push origin main` when ready.\n'));
321
+ }
322
+ }
288
323
  }
289
324
  catch (err) {
290
325
  console.log(pc.red('Failed to merge. You may need to resolve conflicts manually.\n'));
@@ -406,6 +441,22 @@ export async function postTaskFlow(options) {
406
441
  }
407
442
  console.log();
408
443
  }
444
+ /**
445
+ * Launch Claude to resolve merge conflicts
446
+ */
447
+ async function launchClaudeForMerge(options) {
448
+ const { cwd, apiKey } = options;
449
+ const prompt = 'Merge origin/main into the current branch and resolve any conflicts. Run: git merge origin/main --no-edit. If there are conflicts, resolve them, then stage and commit.';
450
+ await new Promise((resolve) => {
451
+ const child = spawn('claude', [prompt], {
452
+ cwd,
453
+ stdio: 'inherit',
454
+ env: { ...process.env, DAMPER_API_KEY: apiKey },
455
+ });
456
+ child.on('error', () => resolve());
457
+ child.on('close', () => resolve());
458
+ });
459
+ }
409
460
  /**
410
461
  * Check if Claude Code CLI is installed
411
462
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@damper/cli",
3
- "version": "0.8.0",
3
+ "version": "0.9.1",
4
4
  "description": "CLI tool for orchestrating Damper task workflows with Claude Code",
5
5
  "author": "Damper <hello@usedamper.com>",
6
6
  "repository": {