ai-project-manage-cli 8.0.1 → 8.0.2

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.
@@ -84,10 +84,6 @@ var requestConfig = {
84
84
  method: "GET",
85
85
  path: "/cli/workspaces/baseline"
86
86
  }),
87
- matchRepository: defineEndpoint({
88
- method: "GET",
89
- path: "/cli/repositories/match"
90
- }),
91
87
  createWebIdeDraftPullRequest: defineEndpoint({
92
88
  method: "POST",
93
89
  path: "/cli/webide/draft-pull-requests"
@@ -112,22 +108,6 @@ var requestConfig = {
112
108
  method: "DELETE",
113
109
  path: "/cli/project-documents"
114
110
  }),
115
- createTaskDeployment: defineEndpoint({
116
- method: "POST",
117
- path: "/cli/task-deployments"
118
- }),
119
- updateTaskDeploymentStatus: defineEndpoint({
120
- method: "PUT",
121
- path: "/cli/task-deployments/status"
122
- }),
123
- syncTaskDeploymentLog: defineEndpoint({
124
- method: "PUT",
125
- path: "/cli/task-deployments/log"
126
- }),
127
- completeTaskDeployment: defineEndpoint({
128
- method: "PUT",
129
- path: "/cli/task-deployments/complete"
130
- }),
131
111
  getDeployArtifactStorage: defineEndpoint(
132
112
  {
133
113
  method: "GET",
@@ -137,10 +117,6 @@ var requestConfig = {
137
117
  getApmLogStorage: defineEndpoint({
138
118
  method: "GET",
139
119
  path: "/cli/apm-log-storage"
140
- }),
141
- attachTaskDeploymentArtifact: defineEndpoint({
142
- method: "PUT",
143
- path: "/cli/task-deployments/artifact"
144
120
  })
145
121
  }
146
122
  };
@@ -564,87 +540,6 @@ var FEATURE_BRANCH_RE = /^feat\/task-.+/;
564
540
  function isFeatureBranchName(branch) {
565
541
  return FEATURE_BRANCH_RE.test(branch.trim().replace(/^origin\//, ""));
566
542
  }
567
- async function resolveFeatureBranchBaseFromGit(cwd, headBranch) {
568
- const head = headBranch.trim().replace(/^origin\//, "");
569
- if (!head) {
570
- throw new Error("[apm] head \u5206\u652F\u540D\u4E3A\u7A7A\uFF0C\u65E0\u6CD5\u63A8\u65AD\u57FA\u7EBF");
571
- }
572
- try {
573
- const reflog = await execGit(
574
- cwd,
575
- ["reflog", "show", "--date=iso", head],
576
- true
577
- );
578
- for (const line of reflog.split("\n")) {
579
- const created = line.match(
580
- /Created from (?:refs\/remotes\/origin\/|origin\/)?(\S+)/i
581
- );
582
- if (created?.[1]) {
583
- const name = created[1].replace(/^origin\//, "");
584
- if (name && name !== head && !isFeatureBranchName(name)) {
585
- return name;
586
- }
587
- }
588
- const moving = line.match(
589
- /checkout: moving from (\S+) to (?:origin\/)?\S+/i
590
- );
591
- if (moving?.[1]) {
592
- const from = moving[1].replace(/^origin\//, "");
593
- if (from && from !== head && !isFeatureBranchName(from)) {
594
- return from;
595
- }
596
- }
597
- }
598
- } catch {
599
- }
600
- await execGit(cwd, ["fetch", "origin", "--prune"], true);
601
- let headRef = head;
602
- try {
603
- await execGit(cwd, ["rev-parse", "--verify", `origin/${head}`], true);
604
- headRef = `origin/${head}`;
605
- } catch {
606
- await execGit(cwd, ["rev-parse", "--verify", head], true);
607
- }
608
- const refsOut = await execGit(
609
- cwd,
610
- ["for-each-ref", "--format=%(refname:short)", "refs/remotes/origin/"],
611
- true
612
- );
613
- let best = null;
614
- for (const ref of refsOut.split("\n").map((s) => s.trim()).filter(Boolean)) {
615
- const name = ref.replace(/^origin\//, "");
616
- if (!name || name === "HEAD" || name === head || isFeatureBranchName(name)) {
617
- continue;
618
- }
619
- try {
620
- await execGit(
621
- cwd,
622
- ["merge-base", "--is-ancestor", `origin/${name}`, headRef],
623
- true
624
- );
625
- const ahead = Number.parseInt(
626
- (await execGit(
627
- cwd,
628
- ["rev-list", "--count", `origin/${name}..${headRef}`],
629
- true
630
- )).trim(),
631
- 10
632
- );
633
- if (!Number.isFinite(ahead) || ahead < 0) continue;
634
- if (!best || ahead < best.ahead) {
635
- best = { name, ahead };
636
- }
637
- } catch {
638
- continue;
639
- }
640
- }
641
- if (best) {
642
- return best.name;
643
- }
644
- throw new Error(
645
- `[apm] \u65E0\u6CD5\u63A8\u65AD ${head} \u57FA\u4E8E\u54EA\u6761\u5206\u652F\u521B\u5EFA\uFF0C\u8BF7\u786E\u8BA4\u672C\u5730 reflog \u6216 origin \u8FDC\u7A0B\u5206\u652F`
646
- );
647
- }
648
543
  async function hasUpstream(cwd) {
649
544
  try {
650
545
  await execGit(cwd, ["rev-parse", "--abbrev-ref", "@{upstream}"], true);
@@ -2740,7 +2635,7 @@ async function ensureWebIdePullRequests(cfg, taskId, workdir) {
2740
2635
  };
2741
2636
  }
2742
2637
  if (!projectBaseBranch) {
2743
- const tip = "\u9879\u76EE\u672A\u914D\u7F6E\u57FA\u7840\u5206\u652F\uFF0C\u65E0\u6CD5\u6309\u57FA\u7EBF\u5339\u914D\u5E73\u53F0\u4ED3\u5E93";
2638
+ const tip = "\u9879\u76EE\u672A\u914D\u7F6E\u57FA\u7840\u5206\u652F\uFF0C\u65E0\u6CD5\u521B\u5EFA PR";
2744
2639
  console.warn(`[apm] WebIDE PR\uFF1A${tip}`);
2745
2640
  return {
2746
2641
  ...empty(),
@@ -2790,7 +2685,7 @@ async function ensureWebIdePullRequests(cfg, taskId, workdir) {
2790
2685
  continue;
2791
2686
  }
2792
2687
  const headBranch = current;
2793
- const originUrl = await tryReadGitOriginUrl(gitRoot);
2688
+ const originUrl = await tryReadHttpsGitOriginUrl(gitRoot) ?? await tryReadGitOriginUrl(gitRoot);
2794
2689
  if (!originUrl) {
2795
2690
  const tip = `${label}\uFF1A\u65E0 remote.origin.url`;
2796
2691
  console.warn(`[apm] WebIDE PR\uFF1A\u8DF3\u8FC7 ${tip}`);
@@ -2804,29 +2699,7 @@ async function ensureWebIdePullRequests(cfg, taskId, workdir) {
2804
2699
  });
2805
2700
  continue;
2806
2701
  }
2807
- const matched = await api.cli.matchRepository({
2808
- url: originUrl,
2809
- baseBranch: projectBaseBranch
2810
- });
2811
- const repositoryId = matched.repositoryId?.trim();
2812
- if (!repositoryId) {
2813
- const tip = `${label}\uFF1A\u5E73\u53F0\u672A\u627E\u5230\u4ED3\u5E93\uFF08remote=${originUrl}\uFF0C\u57FA\u7EBF=${projectBaseBranch}\uFF09`;
2814
- console.warn(`[apm] WebIDE PR\uFF1A\u8DF3\u8FC7 ${tip}`);
2815
- tips.push(tip);
2816
- skipped += 1;
2817
- items.push({
2818
- label,
2819
- outcome: "skipped",
2820
- headBranch,
2821
- baseBranch: projectBaseBranch,
2822
- detail: tip
2823
- });
2824
- continue;
2825
- }
2826
- const baseBranch = await resolveFeatureBranchBaseFromGit(
2827
- gitRoot,
2828
- headBranch
2829
- );
2702
+ const baseBranch = projectBaseBranch;
2830
2703
  const hasChanges = await branchHasChangesAgainstBase(
2831
2704
  gitRoot,
2832
2705
  baseBranch,
@@ -2848,7 +2721,7 @@ async function ensureWebIdePullRequests(cfg, taskId, workdir) {
2848
2721
  }
2849
2722
  const pr = await api.cli.createWebIdeDraftPullRequest({
2850
2723
  taskId,
2851
- repositoryId,
2724
+ originUrl,
2852
2725
  headBranch,
2853
2726
  baseBranch
2854
2727
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-project-manage-cli",
3
- "version": "8.0.1",
3
+ "version": "8.0.2",
4
4
  "description": "命令行工具:后续用于调用平台后端 API 完成运维与自动化操作",
5
5
  "type": "module",
6
6
  "private": false,