ai-project-manage-cli 8.1.16 → 8.1.18

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/worker-script.js +110 -26
  2. package/package.json +1 -1
@@ -536,14 +536,6 @@ function taskIdFromFeatureBranch(branch) {
536
536
  const id = match?.[1]?.trim() ?? "";
537
537
  return id || null;
538
538
  }
539
- async function hasUpstream(cwd) {
540
- try {
541
- await execGit(cwd, ["rev-parse", "--abbrev-ref", "@{upstream}"], true);
542
- return true;
543
- } catch {
544
- return false;
545
- }
546
- }
547
539
  async function pushCurrentBranch(cwd) {
548
540
  if (!await isGitRepo(cwd)) {
549
541
  return false;
@@ -553,11 +545,7 @@ async function pushCurrentBranch(cwd) {
553
545
  console.log("[apm] \u672A\u914D\u7F6E remote.origin\uFF0C\u8DF3\u8FC7 push");
554
546
  return false;
555
547
  }
556
- if (await hasUpstream(cwd)) {
557
- await execGit(cwd, ["push"]);
558
- } else {
559
- await execGit(cwd, ["push", "-u", "origin", "HEAD"]);
560
- }
548
+ await execGit(cwd, ["push", "-u", "origin", "HEAD"]);
561
549
  return true;
562
550
  }
563
551
 
@@ -895,6 +883,7 @@ async function ensureFeatureBranch(branch, baselineBranch, options) {
895
883
  try {
896
884
  await execGit(gitRoot, [
897
885
  "checkout",
886
+ "--no-track",
898
887
  "-b",
899
888
  branch,
900
889
  `origin/${baselineBranch}`
@@ -2457,7 +2446,9 @@ function createPtySessionMcpServers(cfg2) {
2457
2446
  }
2458
2447
 
2459
2448
  // src/commands/connect/local-sqlite-agent-store.ts
2460
- import { composeLocalAgentStore } from "@cursor/sdk";
2449
+ import {
2450
+ composeLocalAgentStore
2451
+ } from "@cursor/sdk";
2461
2452
  import { SqliteLocalAgentStore } from "@cursor/sdk/sqlite";
2462
2453
 
2463
2454
  // src/commands/connect/remote-local-agent-store.ts
@@ -2701,6 +2692,74 @@ async function openSqliteLocalAgentStore(workspaceRef) {
2701
2692
  sqliteByKey.set(cwd, pending2);
2702
2693
  return pending2;
2703
2694
  }
2695
+ function jsonSafePayload(value) {
2696
+ if (value == null) return null;
2697
+ try {
2698
+ return JSON.parse(JSON.stringify(value));
2699
+ } catch {
2700
+ return null;
2701
+ }
2702
+ }
2703
+ function mirrorRunEventsForVisualization(cfg2, local) {
2704
+ const api = createApmApiClient(cfg2);
2705
+ const queues = /* @__PURE__ */ new Map();
2706
+ const draining = /* @__PURE__ */ new Set();
2707
+ const drain = async (runId) => {
2708
+ if (draining.has(runId)) return;
2709
+ draining.add(runId);
2710
+ try {
2711
+ for (; ; ) {
2712
+ const pending2 = queues.get(runId);
2713
+ if (!pending2 || pending2.length === 0) {
2714
+ queues.delete(runId);
2715
+ return;
2716
+ }
2717
+ const batch = pending2.splice(0, 200);
2718
+ try {
2719
+ await api.cli.cursorStoreAppendRunEvents({ events: batch });
2720
+ } catch (err) {
2721
+ console.warn(
2722
+ `[apm] runEvents \u53EF\u89C6\u5316\u540C\u6B65\u5931\u8D25 runId=${runId} n=${batch.length}:`,
2723
+ err instanceof Error ? err.message : err
2724
+ );
2725
+ }
2726
+ }
2727
+ } finally {
2728
+ draining.delete(runId);
2729
+ if ((queues.get(runId)?.length ?? 0) > 0) void drain(runId);
2730
+ }
2731
+ };
2732
+ return {
2733
+ async append(input) {
2734
+ const row = await local.append(input);
2735
+ const queued = queues.get(input.runId) ?? [];
2736
+ queued.push({
2737
+ runId: input.runId,
2738
+ eventType: input.eventType,
2739
+ payload: jsonSafePayload(input.payload),
2740
+ payloadRef: input.payloadRef ?? null,
2741
+ idempotencyKey: input.idempotencyKey ?? `${input.runId}:${row.seq}`,
2742
+ createdAt: row.createdAt
2743
+ });
2744
+ queues.set(input.runId, queued);
2745
+ void drain(input.runId);
2746
+ return row;
2747
+ },
2748
+ list: (input) => local.list(input),
2749
+ async delete(input) {
2750
+ await local.delete(input);
2751
+ const runIds = input.filter.runIds?.map((id) => id.trim()).filter(Boolean);
2752
+ if (!runIds?.length) return;
2753
+ for (const runId of runIds) queues.delete(runId);
2754
+ void api.cli.cursorStoreDeleteRunEvents({ runIds }).catch((err) => {
2755
+ console.warn(
2756
+ `[apm] runEvents \u53EF\u89C6\u5316\u6E05\u7406\u5931\u8D25:`,
2757
+ err instanceof Error ? err.message : err
2758
+ );
2759
+ });
2760
+ }
2761
+ };
2762
+ }
2704
2763
  async function createApmCursorAgentStore(cfg2, workspaceRef) {
2705
2764
  const cwd = workspaceRef.trim();
2706
2765
  const [sqlite, remote] = await Promise.all([
@@ -2711,7 +2770,7 @@ async function createApmCursorAgentStore(cfg2, workspaceRef) {
2711
2770
  agents: remote.agents,
2712
2771
  runs: remote.runs,
2713
2772
  checkpoints: sqlite.checkpoints,
2714
- runEvents: sqlite.runEvents
2773
+ runEvents: mirrorRunEventsForVisualization(cfg2, sqlite.runEvents)
2715
2774
  });
2716
2775
  }
2717
2776
  async function purgeLocalSqliteAgentData(input) {
@@ -4094,6 +4153,17 @@ async function purgeCursorAgentStoreForAgent(cfg2, agentId, workspaceRef) {
4094
4153
  runIds
4095
4154
  });
4096
4155
  }
4156
+ if (runIds.length > 0) {
4157
+ try {
4158
+ const api = createApmApiClient(cfg2);
4159
+ await api.cli.cursorStoreDeleteRunEvents({ runIds });
4160
+ } catch (err) {
4161
+ console.warn(
4162
+ `[apm] \u6E05\u7406\u5E73\u53F0 runEvents \u5931\u8D25 agentId=${trimmedAgentId}:`,
4163
+ err instanceof Error ? err.message : err
4164
+ );
4165
+ }
4166
+ }
4097
4167
  return true;
4098
4168
  }
4099
4169
  async function cleanWebIdeWorkspaceCache(taskId, workdir, cfg2) {
@@ -5288,18 +5358,32 @@ ${assumptionAnswersText}` : msg2.content,
5288
5358
  }
5289
5359
  if (shouldCommitAfterWebIdeMessage(effectiveAction)) {
5290
5360
  if (signal.aborted) throw new Error("\u4EFB\u52A1\u5DF2\u53D6\u6D88");
5291
- const committed = await commitWorkspaceReposIfDirty(
5292
- workdir,
5293
- `chore(webide): sync after ${effectiveAction} (${taskId})`
5294
- );
5295
- console.log(
5296
- `[apm] webide \u515C\u5E95 commit action=${effectiveAction} repos=${committed}`
5297
- );
5361
+ try {
5362
+ const committed = await commitWorkspaceReposIfDirty(
5363
+ workdir,
5364
+ `chore(webide): sync after ${effectiveAction} (${taskId})`
5365
+ );
5366
+ console.log(
5367
+ `[apm] webide \u515C\u5E95 commit action=${effectiveAction} repos=${committed}`
5368
+ );
5369
+ } catch (err) {
5370
+ console.warn(
5371
+ `[apm] webide \u515C\u5E95 commit \u5931\u8D25\uFF08\u4E0D\u963B\u65AD\u5B8C\u6210\uFF09 action=${effectiveAction}:`,
5372
+ err instanceof Error ? err.message : err
5373
+ );
5374
+ }
5298
5375
  if (signal.aborted) throw new Error("\u4EFB\u52A1\u5DF2\u53D6\u6D88");
5299
- const pushed = await pushWorkspaceRepos(workdir);
5300
- console.log(
5301
- `[apm] webide \u81EA\u52A8 push action=${effectiveAction} repos=${pushed}`
5302
- );
5376
+ try {
5377
+ const pushed = await pushWorkspaceRepos(workdir);
5378
+ console.log(
5379
+ `[apm] webide \u81EA\u52A8 push action=${effectiveAction} repos=${pushed}`
5380
+ );
5381
+ } catch (err) {
5382
+ console.warn(
5383
+ `[apm] webide \u81EA\u52A8 push \u5931\u8D25\uFF08\u4E0D\u963B\u65AD\u5B8C\u6210\uFF09 action=${effectiveAction}:`,
5384
+ err instanceof Error ? err.message : err
5385
+ );
5386
+ }
5303
5387
  }
5304
5388
  if (shouldEnsureWebIdePullRequestsAfterAgent(effectiveAction)) {
5305
5389
  if (signal.aborted) throw new Error("\u4EFB\u52A1\u5DF2\u53D6\u6D88");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-project-manage-cli",
3
- "version": "8.1.16",
3
+ "version": "8.1.18",
4
4
  "description": "命令行工具:后续用于调用平台后端 API 完成运维与自动化操作",
5
5
  "type": "module",
6
6
  "private": false,