ai-project-manage-cli 6.0.72 → 6.0.74

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 +80 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1757,8 +1757,33 @@ async function fetchPublishedVersion(spec) {
1757
1757
  async function fetchLatestPublishedVersion() {
1758
1758
  return fetchPublishedVersion("latest");
1759
1759
  }
1760
+ function compareSemverDescending(a, b) {
1761
+ const pa = a.split(".").map((p) => Number.parseInt(p, 10) || 0);
1762
+ const pb = b.split(".").map((p) => Number.parseInt(p, 10) || 0);
1763
+ const len = Math.max(pa.length, pb.length);
1764
+ for (let i = 0; i < len; i++) {
1765
+ const diff = (pb[i] ?? 0) - (pa[i] ?? 0);
1766
+ if (diff !== 0) return diff;
1767
+ }
1768
+ return 0;
1769
+ }
1760
1770
  async function fetchLatestPublishedVersionInMajor(major) {
1761
- return fetchPublishedVersion(String(major));
1771
+ const tagVersion = await fetchPublishedVersion(String(major));
1772
+ if (tagVersion) return tagVersion;
1773
+ const url = `${registryBaseUrl()}/${CLI_PACKAGE_NAME}`;
1774
+ try {
1775
+ const res = await fetch(url);
1776
+ if (!res.ok) return null;
1777
+ const data = await res.json();
1778
+ const versions = Object.keys(data.versions ?? {}).filter(
1779
+ (v) => parseMajorVersion(v) === major
1780
+ );
1781
+ if (versions.length === 0) return null;
1782
+ versions.sort(compareSemverDescending);
1783
+ return versions[0] ?? null;
1784
+ } catch {
1785
+ return null;
1786
+ }
1762
1787
  }
1763
1788
  function resolveUpdateTarget(input) {
1764
1789
  const { current, allowMajorUpgrade, latestInMajor, globalLatest } = input;
@@ -1778,10 +1803,13 @@ function resolveUpdateTarget(input) {
1778
1803
  if (latestInMajor && latestInMajor === current) {
1779
1804
  return { action: "skip" };
1780
1805
  }
1806
+ if (!latestInMajor && globalLatest && parseMajorVersion(globalLatest) === currentMajor && globalLatest === current) {
1807
+ return { action: "skip" };
1808
+ }
1781
1809
  const majorUpgradeAvailable = globalLatest && parseMajorVersion(globalLatest) > currentMajor ? globalLatest : null;
1782
1810
  return {
1783
1811
  action: "install",
1784
- installSpec: `${CLI_PACKAGE_NAME}@${currentMajor}`,
1812
+ installSpec: latestInMajor ? `${CLI_PACKAGE_NAME}@${latestInMajor}` : `${CLI_PACKAGE_NAME}@${currentMajor}`,
1785
1813
  targetLabel: latestInMajor ?? String(currentMajor),
1786
1814
  expectedVersion: latestInMajor,
1787
1815
  majorUpgradeAvailable
@@ -1831,14 +1859,17 @@ async function runUpdate(options = {}) {
1831
1859
  process.exit(install.status ?? 1);
1832
1860
  }
1833
1861
  const after = readCliVersion();
1862
+ const expectedBump = resolved.expectedVersion !== null && resolved.expectedVersion !== current;
1834
1863
  if (resolved.expectedVersion && after === resolved.expectedVersion) {
1835
1864
  console.log(`[apm] \u5DF2\u66F4\u65B0\u5230 ${after}`);
1836
- } else {
1865
+ } else if (expectedBump) {
1837
1866
  console.log(
1838
1867
  `[apm] \u66F4\u65B0\u5B8C\u6210\u3002\u82E5\u7248\u672C\u53F7\u672A\u53D8\u5316\uFF0C\u8BF7\u5728\u65B0\u7EC8\u7AEF\u6267\u884C apm -V \u786E\u8BA4\uFF08\u5168\u5C40\u5B89\u88C5\u8DEF\u5F84\u53EF\u80FD\u672A\u5237\u65B0\uFF09`
1839
1868
  );
1869
+ } else {
1870
+ console.log(`[apm] \u5DF2\u662F\u6700\u65B0\u7248\u672C ${current}`);
1840
1871
  }
1841
- return { didUpdate: true };
1872
+ return { didUpdate: expectedBump };
1842
1873
  }
1843
1874
 
1844
1875
  // src/commands/update-skills.ts
@@ -4230,6 +4261,42 @@ async function runCursorAgent(cfg, ctx, options) {
4230
4261
  }
4231
4262
  }
4232
4263
 
4264
+ // src/commands/connect/ensure-message-reply.ts
4265
+ var DEFAULT_REPLY = "\u4EFB\u52A1\u5DF2\u5B8C\u6210\u3002";
4266
+ function resolveMessageReplyFallback(fallback) {
4267
+ for (const candidate of [
4268
+ fallback.assistantText,
4269
+ fallback.result,
4270
+ fallback.createPlan
4271
+ ]) {
4272
+ const trimmed = candidate?.trim();
4273
+ if (trimmed) {
4274
+ return trimmed;
4275
+ }
4276
+ }
4277
+ return DEFAULT_REPLY;
4278
+ }
4279
+ async function fetchMessageContent(cfg, sessionId, messageId) {
4280
+ const api = createApmApiClient(cfg);
4281
+ const messages = await api.cli.listSessionMessages({ sessionId });
4282
+ const message = messages.find((item) => item.id === messageId);
4283
+ if (!message) {
4284
+ throw new Error(`\u6D88\u606F\u4E0D\u5B58\u5728: ${messageId}`);
4285
+ }
4286
+ return message.content.trim();
4287
+ }
4288
+ async function ensureMessageHasReply(cfg, sessionId, messageId, fallback) {
4289
+ const existing = await fetchMessageContent(cfg, sessionId, messageId);
4290
+ if (existing) {
4291
+ return;
4292
+ }
4293
+ const content = resolveMessageReplyFallback(fallback);
4294
+ await appendMessageContent(cfg, messageId, content);
4295
+ console.log(
4296
+ `[apm] \u6D88\u606F\u65E0\u56DE\u590D\u5185\u5BB9\uFF0C\u5DF2\u81EA\u52A8\u8FFD\u52A0: messageId=${messageId} len=${content.length}`
4297
+ );
4298
+ }
4299
+
4233
4300
  // src/commands/connect/cli-version-sync.ts
4234
4301
  import { existsSync as existsSync16, readFileSync as readFileSync14, writeFileSync as writeFileSync12 } from "fs";
4235
4302
  import { join as join15 } from "path";
@@ -4423,7 +4490,7 @@ async function handleInboundMessage(cfg, msg, signal, ctx) {
4423
4490
  () => syncRepositoryProjectDocumentsPull(workdir, apmRoot)
4424
4491
  );
4425
4492
  }
4426
- await runStep(
4493
+ const agentResult = await runStep(
4427
4494
  "cursor-agent",
4428
4495
  () => runCursorAgent(
4429
4496
  cfg,
@@ -4439,6 +4506,14 @@ async function handleInboundMessage(cfg, msg, signal, ctx) {
4439
4506
  { signal }
4440
4507
  )
4441
4508
  );
4509
+ await runStep(
4510
+ "ensure-reply",
4511
+ () => ensureMessageHasReply(cfg, msg.sessionId, messageId, {
4512
+ assistantText: agentResult.assistantText,
4513
+ result: agentResult.result,
4514
+ createPlan: agentResult.createPlan
4515
+ })
4516
+ );
4442
4517
  await runStep(
4443
4518
  "sync-documents",
4444
4519
  () => syncSessionDocuments(cfg, msg.sessionId, apmRoot)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-project-manage-cli",
3
- "version": "6.0.72",
3
+ "version": "6.0.74",
4
4
  "description": "命令行工具:后续用于调用平台后端 API 完成运维与自动化操作",
5
5
  "type": "module",
6
6
  "private": false,