ai-project-manage-cli 5.0.9 → 5.0.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.
Files changed (2) hide show
  1. package/dist/index.js +23 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -410,18 +410,30 @@ async function ensureFeatureBranch(branch, baselineBranch, options) {
410
410
  await execGit(cwd, ["fetch", "origin", branch]);
411
411
  await execGit(cwd, ["checkout", "-B", branch, `origin/${branch}`]);
412
412
  } else if (await localBranchExists(cwd, branch)) {
413
- throw new Error(
414
- `[apm] \u8FDC\u7A0B\u4E0D\u5B58\u5728\u5206\u652F ${branch}\uFF0C\u4F46\u672C\u5730\u5DF2\u5B58\u5728\u8BE5\u5206\u652F\uFF0C\u8BF7\u5148\u63A8\u9001\u6216\u5220\u9664\u672C\u5730\u5206\u652F`
415
- );
413
+ if (await getCurrentBranch(cwd) !== branch) {
414
+ await execGit(cwd, ["checkout", branch]);
415
+ }
416
+ console.log(`[apm] \u5206\u652F ${branch} \u5DF2\u5B58\u5728\uFF0C\u8DF3\u8FC7\u521B\u5EFA`);
416
417
  } else {
417
418
  await execGit(cwd, ["fetch", "origin", baselineBranch]);
418
- await execGit(cwd, [
419
- "checkout",
420
- "-b",
421
- branch,
422
- `origin/${baselineBranch}`
423
- ]);
424
- await execGit(cwd, ["push", "-u", "origin", branch]);
419
+ try {
420
+ await execGit(cwd, [
421
+ "checkout",
422
+ "-b",
423
+ branch,
424
+ `origin/${baselineBranch}`
425
+ ]);
426
+ await execGit(cwd, ["push", "-u", "origin", branch]);
427
+ } catch (err) {
428
+ if (await localBranchExists(cwd, branch)) {
429
+ if (await getCurrentBranch(cwd) !== branch) {
430
+ await execGit(cwd, ["checkout", branch]);
431
+ }
432
+ console.log(`[apm] \u5206\u652F ${branch} \u5DF2\u5B58\u5728\uFF0C\u8DF3\u8FC7\u521B\u5EFA`);
433
+ } else {
434
+ throw err;
435
+ }
436
+ }
425
437
  }
426
438
  }
427
439
  console.log(`[apm] \u5DF2\u5C31\u7EEA\u5206\u652F ${branch}`);
@@ -1041,7 +1053,7 @@ async function handleInboundMessage(cfg, raw) {
1041
1053
  const messageId = msg.messageId;
1042
1054
  try {
1043
1055
  await runBranch(msg.sessionId, { cwd: msg.workdir });
1044
- await runPull(msg.sessionId, msg.workdir);
1056
+ await runPull(msg.sessionId, workspaceApmDir(msg.workdir));
1045
1057
  await updateMessageStatus(cfg, messageId, "TYPING");
1046
1058
  await runCursorAgent(cfg, {
1047
1059
  messageId: msg.messageId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-project-manage-cli",
3
- "version": "5.0.9",
3
+ "version": "5.0.11",
4
4
  "description": "命令行工具:后续用于调用平台后端 API 完成运维与自动化操作",
5
5
  "type": "module",
6
6
  "private": false,