ai-project-manage-cli 6.0.72 → 6.0.73

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 +35 -4
  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
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.73",
4
4
  "description": "命令行工具:后续用于调用平台后端 API 完成运维与自动化操作",
5
5
  "type": "module",
6
6
  "private": false,