ai-project-manage-cli 8.1.25 → 8.1.26

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 -92
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -568,8 +568,6 @@ async function runLogin(opts) {
568
568
 
569
569
  // src/commands/update.ts
570
570
  import { spawnSync } from "child_process";
571
- import { existsSync as existsSync3 } from "fs";
572
- import { join as join5 } from "path";
573
571
 
574
572
  // src/version.ts
575
573
  import { readFileSync as readFileSync3 } from "fs";
@@ -588,7 +586,6 @@ function readCliVersion() {
588
586
  }
589
587
 
590
588
  // src/commands/update.ts
591
- var APM_SKIP_SELF_UPDATE_ENV = "APM_SKIP_SELF_UPDATE";
592
589
  var useNpmShell = process.platform === "win32";
593
590
  function runNpm(args, options = {}) {
594
591
  return spawnSync(useNpmShell ? "npm.cmd" : "npm", args, {
@@ -681,17 +678,10 @@ function npmAvailable() {
681
678
  return !r.error && r.status === 0;
682
679
  }
683
680
  async function runUpdate(options = {}) {
684
- if (process.env[APM_SKIP_SELF_UPDATE_ENV] === "1") {
685
- return { didUpdate: false };
686
- }
687
681
  const current = readCliVersion();
688
682
  const currentMajor = parseMajorVersion(current);
689
683
  const globalLatest = await fetchLatestPublishedVersion();
690
684
  const latestInMajor = options.allowMajorUpgrade ? null : await fetchLatestPublishedVersionInMajor(currentMajor);
691
- if (options.quietIfCurrent && !options.allowMajorUpgrade && !latestInMajor && !globalLatest) {
692
- console.warn(`[apm] \u65E0\u6CD5\u68C0\u6D4B\u6700\u65B0\u7248\u672C\uFF0C\u7EE7\u7EED\u4F7F\u7528\u5F53\u524D ${current}`);
693
- return { didUpdate: false };
694
- }
695
685
  const resolved = resolveUpdateTarget({
696
686
  current,
697
687
  allowMajorUpgrade: options.allowMajorUpgrade,
@@ -699,10 +689,8 @@ async function runUpdate(options = {}) {
699
689
  globalLatest
700
690
  });
701
691
  if (resolved.action === "skip") {
702
- if (!options.quietIfCurrent) {
703
- console.log(`[apm] \u5DF2\u662F\u6700\u65B0\u7248\u672C ${current}`);
704
- }
705
- return { didUpdate: false };
692
+ console.log(`[apm] \u5DF2\u662F\u6700\u65B0\u7248\u672C ${current}`);
693
+ return;
706
694
  }
707
695
  if (resolved.majorUpgradeAvailable) {
708
696
  console.log(
@@ -739,61 +727,14 @@ async function runUpdate(options = {}) {
739
727
  } else {
740
728
  console.log(`[apm] \u5DF2\u662F\u6700\u65B0\u7248\u672C ${current}`);
741
729
  }
742
- return { didUpdate: expectedBump };
743
- }
744
- function resolveApmEntryPath(entryArg = process.argv[1]) {
745
- const npmResult = runNpm(["root", "-g"], {
746
- encoding: "utf8",
747
- stdio: ["ignore", "pipe", "pipe"]
748
- });
749
- if (npmResult.status === 0) {
750
- const globalRoot = npmResult.stdout?.toString().trim();
751
- if (globalRoot) {
752
- const candidate = join5(globalRoot, CLI_PACKAGE_NAME, "dist", "index.js");
753
- if (existsSync3(candidate)) {
754
- return candidate;
755
- }
756
- }
757
- }
758
- const fromArgv = entryArg?.trim();
759
- if (fromArgv && existsSync3(fromArgv)) {
760
- return fromArgv;
761
- }
762
- if (fromArgv) {
763
- return fromArgv;
764
- }
765
- console.error("[apm] \u65E0\u6CD5\u89E3\u6790 apm \u5165\u53E3\u8DEF\u5F84");
766
- process.exit(1);
767
- }
768
- function reexecConnectAfterUpdate(options) {
769
- console.log("[apm] \u66F4\u65B0\u5B8C\u6210\uFF0C\u6B63\u5728\u4EE5\u65B0\u7248\u672C\u91CD\u65B0\u8FDE\u63A5\u2026");
770
- const apmScript = resolveApmEntryPath();
771
- const args = [apmScript, "connect"];
772
- const server = options.server?.trim();
773
- if (server) {
774
- args.push("--server", server);
775
- }
776
- const socketServer = options.socketServer?.trim();
777
- if (socketServer) {
778
- args.push("--socket-server", socketServer);
779
- }
780
- const result = spawnSync(process.execPath, args, {
781
- stdio: "inherit",
782
- env: { ...process.env, [APM_SKIP_SELF_UPDATE_ENV]: "1" }
783
- });
784
- if (result.error) {
785
- console.error("[apm] \u91CD\u542F connect \u5931\u8D25:", result.error.message);
786
- process.exit(1);
787
- }
788
- process.exit(result.status ?? 0);
789
730
  }
790
731
 
791
732
  // src/commands/update-skills.ts
792
- import { existsSync as existsSync4, statSync as statSync2 } from "fs";
733
+ import { existsSync as existsSync3, statSync as statSync2 } from "fs";
793
734
  async function syncWorkspaceSkills(workdir) {
794
735
  const apmDir = workspaceApmDir(workdir);
795
736
  const fsApmDir = toFsPath(apmDir);
796
- if (!existsSync4(fsApmDir)) {
737
+ if (!existsSync3(fsApmDir)) {
797
738
  throw new Error("[apm] \u672A\u627E\u5230 .apm \u76EE\u5F55\uFF0C\u8BF7\u5148\u6267\u884C apm init");
798
739
  }
799
740
  const apmStat = statSync2(fsApmDir);
@@ -808,7 +749,7 @@ async function syncWorkspaceSkills(workdir) {
808
749
  }
809
750
  async function runUpdateSkills() {
810
751
  const apmDir = workspaceApmDir();
811
- if (!existsSync4(apmDir)) {
752
+ if (!existsSync3(apmDir)) {
812
753
  console.error("[apm] \u672A\u627E\u5230 .apm \u76EE\u5F55\uFF0C\u8BF7\u5148\u6267\u884C apm init");
813
754
  process.exit(1);
814
755
  }
@@ -961,7 +902,7 @@ function handleSteerAction(payload, ctx) {
961
902
  }
962
903
 
963
904
  // src/commands/connect/core/worker/worker.ts
964
- import { dirname as dirname2, join as join6 } from "path";
905
+ import { dirname as dirname2, join as join5 } from "path";
965
906
  import { fileURLToPath as fileURLToPath2 } from "url";
966
907
  import { Worker } from "node:worker_threads";
967
908
 
@@ -987,7 +928,7 @@ function resolveWebIdeWorkerHeapMb(env = process.env, totalMemoryBytes = totalme
987
928
  }
988
929
 
989
930
  // src/commands/connect/core/worker/worker.ts
990
- var workerFile = join6(
931
+ var workerFile = join5(
991
932
  dirname2(fileURLToPath2(import.meta.url)),
992
933
  "worker-script.js"
993
934
  );
@@ -1153,15 +1094,15 @@ function dispatchConnectAction(payload, ctx) {
1153
1094
 
1154
1095
  // src/commands/connect-lock.ts
1155
1096
  import {
1156
- existsSync as existsSync5,
1097
+ existsSync as existsSync4,
1157
1098
  mkdirSync as mkdirSync4,
1158
1099
  readFileSync as readFileSync4,
1159
1100
  unlinkSync as unlinkSync2,
1160
1101
  writeFileSync as writeFileSync3
1161
1102
  } from "fs";
1162
1103
  import { setTimeout as delay } from "node:timers/promises";
1163
- import { join as join7 } from "path";
1164
- var CONNECT_LOCK_PATH = join7(APM_CONFIG_DIR, "connect.lock");
1104
+ import { join as join6 } from "path";
1105
+ var CONNECT_LOCK_PATH = join6(APM_CONFIG_DIR, "connect.lock");
1165
1106
  var ACQUIRE_RETRY_MS = 5e3;
1166
1107
  var ACQUIRE_RETRY_INTERVAL_MS = 200;
1167
1108
  function isProcessAlive(pid) {
@@ -1174,7 +1115,7 @@ function isProcessAlive(pid) {
1174
1115
  }
1175
1116
  }
1176
1117
  function readConnectLock() {
1177
- if (!existsSync5(CONNECT_LOCK_PATH)) return null;
1118
+ if (!existsSync4(CONNECT_LOCK_PATH)) return null;
1178
1119
  try {
1179
1120
  const raw = readFileSync4(CONNECT_LOCK_PATH, "utf8");
1180
1121
  const parsed = JSON.parse(raw);
@@ -1322,10 +1263,6 @@ function connectOnce(url, ctx, connectionAbort, onConnected) {
1322
1263
  });
1323
1264
  }
1324
1265
  async function runConnect(options) {
1325
- const { didUpdate } = await runUpdate({ quietIfCurrent: true });
1326
- if (didUpdate) {
1327
- reexecConnectAfterUpdate(options);
1328
- }
1329
1266
  const cfg = await ensureLoggedConfig();
1330
1267
  const endpoints = resolveApmEndpoints({
1331
1268
  server: options.server,
@@ -1431,8 +1368,8 @@ async function runConnect(options) {
1431
1368
  }
1432
1369
 
1433
1370
  // src/utils/home-repository.ts
1434
- import { existsSync as existsSync6, readFileSync as readFileSync5 } from "fs";
1435
- import { join as join8, resolve as resolve3 } from "path";
1371
+ import { existsSync as existsSync5, readFileSync as readFileSync5 } from "fs";
1372
+ import { join as join7, resolve as resolve3 } from "path";
1436
1373
  var DEFAULT_REPOS_MANIFEST = "/home/repository.json";
1437
1374
  function isSimpleChildDirName(name) {
1438
1375
  if (!name || name === "." || name === "..") return false;
@@ -1455,7 +1392,7 @@ function loadHomeRepositoryEntries(manifestPath2) {
1455
1392
  throw new Error("[apm] \u591A\u4ED3\u6E05\u5355\u8DEF\u5F84\u4E3A\u7A7A");
1456
1393
  }
1457
1394
  const path = toFsPath(label);
1458
- if (!existsSync6(path)) {
1395
+ if (!existsSync5(path)) {
1459
1396
  throw new Error(`[apm] \u672A\u627E\u5230\u591A\u4ED3\u6E05\u5355 ${label}`);
1460
1397
  }
1461
1398
  let parsed;
@@ -1495,12 +1432,12 @@ function loadHomeRepositoryEntries(manifestPath2) {
1495
1432
  }
1496
1433
  function resolveHomeRepositoryAbsolutePaths(workdirInput, entries) {
1497
1434
  const workdir = resolveWorkdirPath(workdirInput);
1498
- return entries.map((entry) => resolve3(join8(workdir, entry.path)));
1435
+ return entries.map((entry) => resolve3(join7(workdir, entry.path)));
1499
1436
  }
1500
1437
 
1501
1438
  // src/utils/git.ts
1502
1439
  import { execFile } from "child_process";
1503
- import { dirname as dirname3, join as join9 } from "path";
1440
+ import { dirname as dirname3, join as join8 } from "path";
1504
1441
  import { fileURLToPath as fileURLToPath3 } from "url";
1505
1442
  import { promisify } from "util";
1506
1443
  var execFileAsync = promisify(execFile);
@@ -1584,7 +1521,7 @@ async function resolveGitRepoRoot(cwd) {
1584
1521
  return (await execGit(cwd, ["rev-parse", "--show-toplevel"], true)).trim();
1585
1522
  }
1586
1523
  function resolveGitScript(name) {
1587
- return join9(dirname3(fileURLToPath3(import.meta.url)), "scripts", name);
1524
+ return join8(dirname3(fileURLToPath3(import.meta.url)), "scripts", name);
1588
1525
  }
1589
1526
  async function runGitScript(name, options) {
1590
1527
  const skipCode = options.skipCode ?? 2;
@@ -1646,14 +1583,14 @@ import { basename as basename2 } from "path";
1646
1583
 
1647
1584
  // src/utils/workspace-repos.ts
1648
1585
  import {
1649
- existsSync as existsSync7,
1586
+ existsSync as existsSync6,
1650
1587
  mkdirSync as mkdirSync5,
1651
1588
  readFileSync as readFileSync6,
1652
1589
  readdirSync as readdirSync3,
1653
1590
  statSync as statSync3,
1654
1591
  writeFileSync as writeFileSync4
1655
1592
  } from "fs";
1656
- import { basename, dirname as dirname4, join as join10, relative, resolve as resolve4 } from "path";
1593
+ import { basename, dirname as dirname4, join as join9, relative, resolve as resolve4 } from "path";
1657
1594
 
1658
1595
  // src/utils/git-remote.ts
1659
1596
  import { execFile as execFile2 } from "child_process";
@@ -1664,7 +1601,7 @@ var execFileAsync2 = promisify2(execFile2);
1664
1601
  var WORKSPACE_REPOS_MANIFEST = "workspace-repos.json";
1665
1602
  var WORKSPACE_REPOS_VERSION = 1;
1666
1603
  function manifestPath(workdir) {
1667
- return join10(workspaceApmDir(workdir), WORKSPACE_REPOS_MANIFEST);
1604
+ return join9(workspaceApmDir(workdir), WORKSPACE_REPOS_MANIFEST);
1668
1605
  }
1669
1606
  function absoluteRepoPath(workdir, entry) {
1670
1607
  return resolve4(workdir, entry.path);
@@ -1688,7 +1625,7 @@ function normalizeRepoEntry(raw) {
1688
1625
  }
1689
1626
  function readManifest(workdir) {
1690
1627
  const path = toFsPath(manifestPath(workdir));
1691
- if (!existsSync7(path)) {
1628
+ if (!existsSync6(path)) {
1692
1629
  return null;
1693
1630
  }
1694
1631
  try {
@@ -1757,7 +1694,7 @@ function formatRepoLabel(workdir, repoAbs) {
1757
1694
  }
1758
1695
 
1759
1696
  // src/commands/branch.ts
1760
- import { existsSync as existsSync8 } from "fs";
1697
+ import { existsSync as existsSync7 } from "fs";
1761
1698
  var TASK_BRANCH_PREFIX = "feat/task-";
1762
1699
  async function syncTaskRepos(workdir, options = {}) {
1763
1700
  const opts = typeof options === "string" ? { message: options } : options;
@@ -1844,7 +1781,7 @@ function resolveTaskBranchRepoRoots(workdirPath, reposManifest) {
1844
1781
  }
1845
1782
  if (manifestPath2 && isWorkspaceReposManifestFile(manifestPath2)) {
1846
1783
  const fsPath = toFsPath(manifestPath2);
1847
- if (!existsSync8(fsPath)) {
1784
+ if (!existsSync7(fsPath)) {
1848
1785
  throw new Error(`[apm] \u672A\u627E\u5230\u5DE5\u4F5C\u533A\u4ED3\u5E93\u6E05\u5355 ${manifestPath2}`);
1849
1786
  }
1850
1787
  console.log(`[apm] \u4F7F\u7528\u663E\u5F0F\u5DE5\u4F5C\u533A\u4ED3\u5E93\u6E05\u5355 ${manifestPath2}`);
@@ -1933,10 +1870,10 @@ async function runEnsureTaskBranchCli(options = {}) {
1933
1870
 
1934
1871
  // src/utils/user-prompt-cache.ts
1935
1872
  import { createHash } from "crypto";
1936
- import { existsSync as existsSync9, mkdirSync as mkdirSync6, readFileSync as readFileSync7, writeFileSync as writeFileSync5 } from "fs";
1937
- import { join as join11 } from "path";
1873
+ import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync7, writeFileSync as writeFileSync5 } from "fs";
1874
+ import { join as join10 } from "path";
1938
1875
  import { tmpdir } from "os";
1939
- var CACHE_ROOT = join11(tmpdir(), "apm-hooks");
1876
+ var CACHE_ROOT = join10(tmpdir(), "apm-hooks");
1940
1877
  var PROMPT_FILE = "user-prompt.txt";
1941
1878
  var COMMIT_SUBJECT_MAX_LEN = 100;
1942
1879
  function workdirKey(workdir) {
@@ -1944,7 +1881,7 @@ function workdirKey(workdir) {
1944
1881
  }
1945
1882
  function userPromptCachePath(workdirInput) {
1946
1883
  const workdir = resolveWorkdirPath(workdirInput);
1947
- return join11(CACHE_ROOT, workdirKey(workdir), PROMPT_FILE);
1884
+ return join10(CACHE_ROOT, workdirKey(workdir), PROMPT_FILE);
1948
1885
  }
1949
1886
  function formatUserPromptAsCommitMessage(prompt) {
1950
1887
  const oneLine = prompt.replace(/\r\n/g, "\n").replace(/\r/g, "\n").split("\n").map((l) => l.trim()).find((l) => l.length > 0);
@@ -1955,7 +1892,7 @@ function formatUserPromptAsCommitMessage(prompt) {
1955
1892
  }
1956
1893
  function loadUserPromptCommitMessage(workdirInput) {
1957
1894
  const path = toFsPath(userPromptCachePath(workdirInput));
1958
- if (!existsSync9(path)) return null;
1895
+ if (!existsSync8(path)) return null;
1959
1896
  try {
1960
1897
  const raw = readFileSync7(path, "utf8");
1961
1898
  const msg = formatUserPromptAsCommitMessage(raw);
@@ -2080,7 +2017,7 @@ function buildProgram() {
2080
2017
  });
2081
2018
  });
2082
2019
  program.command("connect").description(
2083
- "\u8FDE\u63A5\u524D\u68C0\u6D4B\u5E76\u66F4\u65B0\u5230\u5F53\u524D\u5927\u7248\u672C\u6700\u65B0 CLI\uFF0C\u518D\u8FDE\u63A5\u5E73\u53F0 WebSocket\uFF08/ws/agent\uFF09"
2020
+ "\u8FDE\u63A5\u5E73\u53F0 WebSocket\uFF08/ws/agent\uFF09\uFF0C\u63A5\u624B WebIDE \u5DE5\u4F5C\u6D41\u6D88\u606F\uFF1B\u4E0D\u81EA\u52A8\u5347\u7EA7 CLI"
2084
2021
  ).option(
2085
2022
  "--server <url>",
2086
2023
  "API \u6839\u5730\u5740\uFF1B\u82E5\u53EA\u4F20\u6B64\u9879\u4E14\u5E26\u7AEF\u53E3\uFF0C\u5219\u7AEF\u53E3\u89C6\u4E3A Socket \u7AEF\u53E3\uFF08\u8986\u76D6 config / APM_SERVER\uFF09"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-project-manage-cli",
3
- "version": "8.1.25",
3
+ "version": "8.1.26",
4
4
  "description": "命令行工具:后续用于调用平台后端 API 完成运维与自动化操作",
5
5
  "type": "module",
6
6
  "private": false,