ai-project-manage-cli 6.0.35 → 6.0.36

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 +29 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1440,6 +1440,19 @@ var logCtx = (ctx, agentId) => ({
1440
1440
  messageId: ctx.messageId,
1441
1441
  agentId
1442
1442
  });
1443
+ function formatCursorRunFailure(runId, options) {
1444
+ const details = [
1445
+ options?.statusError?.trim(),
1446
+ options?.resultText?.trim()
1447
+ ].filter((value, index, arr) => {
1448
+ if (!value) return false;
1449
+ return arr.indexOf(value) === index;
1450
+ });
1451
+ if (details.length === 0) {
1452
+ return `Cursor run \u5931\u8D25: ${runId}`;
1453
+ }
1454
+ return `Cursor run \u5931\u8D25: ${runId} \u2014 ${details.join("\uFF1B")}`;
1455
+ }
1443
1456
  async function runCursorAgent(cfg, ctx, options) {
1444
1457
  const signal = options?.signal;
1445
1458
  logAbortSignalStats(signal, "runCursorAgent:start");
@@ -1487,18 +1500,33 @@ async function runCursorAgent(cfg, ctx, options) {
1487
1500
  activeRun = run;
1488
1501
  logAbortSignalStats(signal, "runCursorAgent:after-send");
1489
1502
  console.log(`[apm] Cursor run id=${run.id} agentId=${agent.agentId}`);
1503
+ let lastRunErrorStatus;
1490
1504
  for await (const event of run.stream()) {
1491
1505
  if (signal?.aborted) {
1492
1506
  abortRun();
1493
1507
  throw new Error("\u8FDE\u63A5\u5DF2\u5173\u95ED\uFF0C\u4EFB\u52A1\u4E2D\u65AD");
1494
1508
  }
1509
+ if (event.type === "status" && event.status === "ERROR") {
1510
+ const message = event.message?.trim();
1511
+ if (message) {
1512
+ lastRunErrorStatus = message;
1513
+ console.error(
1514
+ `[apm] Cursor run status=ERROR runId=${run.id}: ${message}`
1515
+ );
1516
+ }
1517
+ }
1495
1518
  eventSession.addEvent(event);
1496
1519
  syncRemoteLog.schedule(eventSession);
1497
1520
  }
1498
1521
  await syncRemoteLog.flush(eventSession);
1499
1522
  const result = await run.wait();
1500
1523
  if (result.status === "error") {
1501
- throw new Error(`Cursor run \u5931\u8D25: ${result.id}`);
1524
+ const failureMessage = formatCursorRunFailure(result.id, {
1525
+ statusError: lastRunErrorStatus,
1526
+ resultText: result.result
1527
+ });
1528
+ console.error(`[apm] ${failureMessage}`);
1529
+ throw new Error(failureMessage);
1502
1530
  }
1503
1531
  if (result.status === "cancelled") {
1504
1532
  throw new Error(`Cursor run \u5DF2\u53D6\u6D88: ${result.id}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-project-manage-cli",
3
- "version": "6.0.35",
3
+ "version": "6.0.36",
4
4
  "description": "命令行工具:后续用于调用平台后端 API 完成运维与自动化操作",
5
5
  "type": "module",
6
6
  "private": false,