ai-project-manage-cli 6.0.110 → 6.0.111

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 +101 -49
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3022,8 +3022,8 @@ var DeployExecutionError = class extends Error {
3022
3022
 
3023
3023
  // src/commands/deploy/deploy-debug-log.ts
3024
3024
  import { spawnSync as spawnSync4 } from "node:child_process";
3025
- import { existsSync as existsSync15 } from "node:fs";
3026
- import { dirname as dirname5, join as join16 } from "node:path";
3025
+ import { existsSync as existsSync16 } from "node:fs";
3026
+ import { dirname as dirname5, join as join17 } from "node:path";
3027
3027
 
3028
3028
  // src/commands/deploy/internal/deploy-artifact-minio.ts
3029
3029
  import { readFile as readFile2 } from "node:fs/promises";
@@ -3277,7 +3277,8 @@ async function uploadDeployArtifactZip(options) {
3277
3277
 
3278
3278
  // src/commands/deploy/internal/deploy-shell-env.ts
3279
3279
  import { spawnSync as spawnSync3 } from "node:child_process";
3280
- import { dirname as dirname4 } from "node:path";
3280
+ import { existsSync as existsSync15 } from "node:fs";
3281
+ import { dirname as dirname4, join as join16 } from "node:path";
3281
3282
 
3282
3283
  // src/commands/daemon.ts
3283
3284
  import { spawnSync as spawnSync2 } from "child_process";
@@ -4053,17 +4054,38 @@ async function runDaemonLogs(options) {
4053
4054
  // src/commands/deploy/internal/deploy-shell-env.ts
4054
4055
  var PATH_SEP = process.platform === "win32" ? ";" : ":";
4055
4056
  var useNpmShell3 = process.platform === "win32";
4056
- function resolveNpmGlobalBin2() {
4057
- const result = spawnSync3(useNpmShell3 ? "npm.cmd" : "npm", ["bin", "-g"], {
4058
- encoding: "utf8",
4059
- shell: useNpmShell3,
4060
- stdio: ["ignore", "pipe", "pipe"]
4061
- });
4062
- if (result.status !== 0) {
4057
+ function readEnvPath(env) {
4058
+ if (process.platform === "win32") {
4059
+ return env.Path ?? env.PATH ?? "";
4060
+ }
4061
+ return env.PATH ?? "";
4062
+ }
4063
+ function writeEnvPath(env, value) {
4064
+ if (process.platform === "win32") {
4065
+ env.Path = value;
4066
+ delete env.PATH;
4067
+ return;
4068
+ }
4069
+ env.PATH = value;
4070
+ }
4071
+ function resolveNodeInstallDir() {
4072
+ return dirname4(process.execPath);
4073
+ }
4074
+ function resolveNpmCmdPath() {
4075
+ if (process.platform !== "win32") {
4063
4076
  return null;
4064
4077
  }
4065
- const bin = result.stdout?.toString().trim();
4066
- return bin || null;
4078
+ const candidate = join16(resolveNodeInstallDir(), "npm.cmd");
4079
+ return existsSync15(candidate) ? candidate : null;
4080
+ }
4081
+ function formatNpmRunShellCommand(scriptName) {
4082
+ const trimmed = scriptName.trim();
4083
+ if (process.platform !== "win32") {
4084
+ return `npm run ${trimmed}`;
4085
+ }
4086
+ const npmCmd = resolveNpmCmdPath();
4087
+ const npm = npmCmd ? `"${npmCmd}"` : "npm.cmd";
4088
+ return `${npm} run ${trimmed}`;
4067
4089
  }
4068
4090
  function prependPath(pathValue, segment) {
4069
4091
  if (!segment) {
@@ -4078,10 +4100,22 @@ function prependPath(pathValue, segment) {
4078
4100
  }
4079
4101
  return `${segment}${PATH_SEP}${pathValue}`;
4080
4102
  }
4103
+ function spawnNpm(args, env) {
4104
+ const npmCmdPath = resolveNpmCmdPath();
4105
+ return spawnSync3(npmCmdPath ?? (useNpmShell3 ? "npm.cmd" : "npm"), args, {
4106
+ encoding: "utf8",
4107
+ shell: useNpmShell3 && !npmCmdPath,
4108
+ env,
4109
+ stdio: ["ignore", "pipe", "pipe"]
4110
+ });
4111
+ }
4112
+ function resolveNpmGlobalBin2() {
4113
+ return resolveNpmGlobalBinWithoutEnv(process.env);
4114
+ }
4081
4115
  function buildDeployShellEnv(extra) {
4082
4116
  const env = { ...process.env, ...extra };
4083
- const pathSegments = [dirname4(process.execPath)];
4084
- const globalBin = resolveNpmGlobalBin2();
4117
+ const pathSegments = [resolveNodeInstallDir()];
4118
+ const globalBin = resolveNpmGlobalBinWithoutEnv(env);
4085
4119
  if (globalBin) {
4086
4120
  pathSegments.push(globalBin);
4087
4121
  }
@@ -4089,11 +4123,29 @@ function buildDeployShellEnv(extra) {
4089
4123
  resolveApmEntryPath();
4090
4124
  } catch {
4091
4125
  }
4126
+ let pathValue = readEnvPath(env);
4092
4127
  for (const segment of pathSegments) {
4093
- env.PATH = prependPath(env.PATH, segment);
4128
+ pathValue = prependPath(pathValue, segment);
4094
4129
  }
4130
+ writeEnvPath(env, pathValue);
4131
+ return env;
4132
+ }
4133
+ function buildDeployShellEnvWithoutGlobalBin(extra) {
4134
+ const env = { ...process.env, ...extra };
4135
+ let pathValue = readEnvPath(env);
4136
+ pathValue = prependPath(pathValue, resolveNodeInstallDir());
4137
+ writeEnvPath(env, pathValue);
4095
4138
  return env;
4096
4139
  }
4140
+ function resolveNpmGlobalBinWithoutEnv(baseEnv) {
4141
+ const env = buildDeployShellEnvWithoutGlobalBin(baseEnv);
4142
+ const result = spawnNpm(["bin", "-g"], env);
4143
+ if (result.status !== 0) {
4144
+ return null;
4145
+ }
4146
+ const bin = result.stdout?.toString().trim();
4147
+ return bin || null;
4148
+ }
4097
4149
 
4098
4150
  // src/commands/deploy/deploy-debug-log.ts
4099
4151
  var LOG_PREFIX = "[apm:deploy-debug]";
@@ -4196,7 +4248,7 @@ function logExecuteDeployContext(input) {
4196
4248
  const deploymentRunId = process.env[APM_DEPLOYMENT_RUN_ID_ENV]?.trim() || null;
4197
4249
  const shellEnv = buildDeployShellEnv();
4198
4250
  const npmGlobalBin = resolveNpmGlobalBin2();
4199
- const packageJsonPath = join16(input.cwd, "package.json");
4251
+ const packageJsonPath = join17(input.cwd, "package.json");
4200
4252
  logLine("========== executeDeploy \u4E0A\u4E0B\u6587 ==========");
4201
4253
  logLine(`trigger=${trigger} deployEnv=${input.env}`);
4202
4254
  logLine(`cwd(input)=${input.cwdInput}`);
@@ -4206,12 +4258,12 @@ function logExecuteDeployContext(input) {
4206
4258
  `cwdMatchProcess=${input.cwd === input.processCwd ? "yes" : "no"} (connect \u901A\u5E38\u4E3A no)`
4207
4259
  );
4208
4260
  logLine(
4209
- `apm.config=${input.apmConfigPath} exists=${existsSync15(
4261
+ `apm.config=${input.apmConfigPath} exists=${existsSync16(
4210
4262
  input.apmConfigPath
4211
4263
  )}`
4212
4264
  );
4213
4265
  logLine(
4214
- `package.json=${packageJsonPath} exists=${existsSync15(packageJsonPath)}`
4266
+ `package.json=${packageJsonPath} exists=${existsSync16(packageJsonPath)}`
4215
4267
  );
4216
4268
  logLine(
4217
4269
  `flags captureOutput=${input.captureOutput} packOnly=${Boolean(
@@ -4232,10 +4284,10 @@ function logExecuteDeployContext(input) {
4232
4284
  )) {
4233
4285
  logLine(` ${key}=${value}`);
4234
4286
  }
4235
- logLine(`process.env.PATH=${summarizePath(process.env.PATH)}`);
4287
+ logLine(`process.env.PATH=${summarizePath(readEnvPath(process.env))}`);
4236
4288
  logLine("--- buildDeployShellEnv()\uFF08\u5B50\u8FDB\u7A0B\u5B9E\u9645 env\uFF09---");
4237
- logLine(describePathDelta(process.env.PATH, shellEnv.PATH));
4238
- logLine(`shellEnv.PATH=${summarizePath(shellEnv.PATH)}`);
4289
+ logLine(describePathDelta(readEnvPath(process.env), readEnvPath(shellEnv)));
4290
+ logLine(`shellEnv.PATH=${summarizePath(readEnvPath(shellEnv))}`);
4239
4291
  for (const [key, value] of Object.entries(
4240
4292
  pickEnvKeys(shellEnv, [APM_DEPLOYMENT_RUN_ID_ENV, "NODE_ENV"])
4241
4293
  )) {
@@ -4254,7 +4306,7 @@ function logRunDeployShellContext(input) {
4254
4306
  `stdio=${input.captureOutput ? "stdin=inherit stdout=pipe stderr=pipe" : "inherit"}`
4255
4307
  );
4256
4308
  logLine(`shell=true maxBuffer=${50 * 1024 * 1024}`);
4257
- logLine(`shellEnv.PATH(head)=${summarizePath(shellEnv.PATH, 8)}`);
4309
+ logLine(`shellEnv.PATH(head)=${summarizePath(readEnvPath(shellEnv), 8)}`);
4258
4310
  logLine("--------------------------------------------");
4259
4311
  }
4260
4312
  function logRunDeployShellResult(input) {
@@ -4267,14 +4319,14 @@ function logWisdomFrontendDeployContext(input) {
4267
4319
  logLine(
4268
4320
  `buildKey=build:${input.env} buildCmd=${input.buildCmd ?? "(missing)"}`
4269
4321
  );
4270
- logLine(`distDir=${input.distDir} exists=${existsSync15(input.distDir)}`);
4322
+ logLine(`distDir=${input.distDir} exists=${existsSync16(input.distDir)}`);
4271
4323
  logLine(
4272
4324
  `packOnly=${input.packOnly} archiveDeployArtifact=${input.archiveDeployArtifact}`
4273
4325
  );
4274
4326
  }
4275
4327
 
4276
4328
  // src/commands/deploy/internal/wisdom-deploy.ts
4277
- import { existsSync as existsSync19, readFileSync as readFileSync15, statSync as statSync9 } from "node:fs";
4329
+ import { existsSync as existsSync20, readFileSync as readFileSync15, statSync as statSync9 } from "node:fs";
4278
4330
  import path10 from "node:path";
4279
4331
 
4280
4332
  // src/commands/deploy/deploy-shell-run.ts
@@ -4383,7 +4435,7 @@ import JSZip2 from "jszip";
4383
4435
 
4384
4436
  // src/commands/deploy/internal/wisdom-backend/manifest.ts
4385
4437
  import {
4386
- existsSync as existsSync16,
4438
+ existsSync as existsSync17,
4387
4439
  mkdirSync as mkdirSync7,
4388
4440
  readFileSync as readFileSync13,
4389
4441
  statSync as statSync6,
@@ -4405,7 +4457,7 @@ function fileSignature(filePath) {
4405
4457
  }
4406
4458
  function loadManifest3() {
4407
4459
  const manifestPath2 = manifestFilePath();
4408
- if (!existsSync16(manifestPath2)) {
4460
+ if (!existsSync17(manifestPath2)) {
4409
4461
  return {};
4410
4462
  }
4411
4463
  return JSON.parse(readFileSync13(manifestPath2, "utf8"));
@@ -4847,7 +4899,7 @@ function listAllLibFilesForArchive(libDir) {
4847
4899
  }
4848
4900
 
4849
4901
  // src/commands/deploy/internal/wisdom-backend/maven-build.ts
4850
- import { existsSync as existsSync18, readdirSync as readdirSync6, statSync as statSync8 } from "node:fs";
4902
+ import { existsSync as existsSync19, readdirSync as readdirSync6, statSync as statSync8 } from "node:fs";
4851
4903
  import path7 from "node:path";
4852
4904
  import { spawnSync as spawnSync6 } from "node:child_process";
4853
4905
  function getMvnExecutable() {
@@ -4896,11 +4948,11 @@ function runMavenBuild(projectRoot, mavenLocalRepo, repoSource) {
4896
4948
  }
4897
4949
  function locateLibDir(projectRoot) {
4898
4950
  const targetDir = getTargetDir(projectRoot);
4899
- if (!existsSync18(targetDir)) {
4951
+ if (!existsSync19(targetDir)) {
4900
4952
  fail(`\u6784\u5EFA\u4EA7\u7269\u76EE\u5F55\u4E0D\u5B58\u5728: ${targetDir}`);
4901
4953
  }
4902
4954
  const libDir = path7.join(targetDir, "lib");
4903
- if (!existsSync18(libDir) || !statSync8(libDir).isDirectory()) {
4955
+ if (!existsSync19(libDir) || !statSync8(libDir).isDirectory()) {
4904
4956
  fail(`lib \u76EE\u5F55\u4E0D\u5B58\u5728: ${libDir}`);
4905
4957
  }
4906
4958
  const libJars = readdirSync6(libDir).filter((name) => name.endsWith(".jar"));
@@ -4912,7 +4964,7 @@ function locateLibDir(projectRoot) {
4912
4964
  }
4913
4965
  function locateMainJar(projectRoot) {
4914
4966
  const targetDir = getTargetDir(projectRoot);
4915
- if (!existsSync18(targetDir)) {
4967
+ if (!existsSync19(targetDir)) {
4916
4968
  fail(`\u6784\u5EFA\u4EA7\u7269\u76EE\u5F55\u4E0D\u5B58\u5728: ${targetDir}`);
4917
4969
  }
4918
4970
  const jarFiles = readdirSync6(targetDir).filter((name) => name.endsWith(".jar") && !name.endsWith(".jar.original")).map((name) => path7.join(targetDir, name)).sort((a, b) => statSync8(b).mtimeMs - statSync8(a).mtimeMs);
@@ -5401,11 +5453,11 @@ function isWisdomDeployConfigured(cfg) {
5401
5453
  return Boolean(w?.host?.trim() && w?.remotePath?.trim());
5402
5454
  }
5403
5455
  function detectWisdomProjectType(cwd) {
5404
- return existsSync19(path10.join(cwd, "package.json")) ? "frontend" : "backend";
5456
+ return existsSync20(path10.join(cwd, "package.json")) ? "frontend" : "backend";
5405
5457
  }
5406
5458
  function readPackageScripts(cwd) {
5407
5459
  const pkgPath = path10.join(cwd, "package.json");
5408
- if (!existsSync19(pkgPath)) {
5460
+ if (!existsSync20(pkgPath)) {
5409
5461
  return {};
5410
5462
  }
5411
5463
  try {
@@ -5420,10 +5472,10 @@ function resolveFrontendBuildCommand(env, cwd) {
5420
5472
  const scripts = readPackageScripts(cwd);
5421
5473
  const buildKey = `build:${env}`;
5422
5474
  if (scripts[buildKey]?.trim()) {
5423
- return `npm run build:${env}`;
5475
+ return formatNpmRunShellCommand(`build:${env}`);
5424
5476
  }
5425
5477
  if (isProductionDeployEnv(env) && scripts.build?.trim()) {
5426
- return "npm run build";
5478
+ return formatNpmRunShellCommand("build");
5427
5479
  }
5428
5480
  return null;
5429
5481
  }
@@ -5432,7 +5484,7 @@ function resolveFrontendDistDir(cwd) {
5432
5484
  for (const rel of candidates) {
5433
5485
  const full = path10.join(cwd, rel);
5434
5486
  try {
5435
- if (existsSync19(full) && statSync9(full).isDirectory()) {
5487
+ if (existsSync20(full) && statSync9(full).isDirectory()) {
5436
5488
  return full;
5437
5489
  }
5438
5490
  } catch {
@@ -5995,7 +6047,7 @@ async function handleInboundDeploy(cfg, msg, signal) {
5995
6047
  }
5996
6048
 
5997
6049
  // src/commands/clean-session-cache.ts
5998
- import { existsSync as existsSync20, rmSync as rmSync4 } from "node:fs";
6050
+ import { existsSync as existsSync21, rmSync as rmSync4 } from "node:fs";
5999
6051
 
6000
6052
  // src/commands/connect/pre-step-cache.ts
6001
6053
  var PULL_TTL_MS = 3e4;
@@ -6037,7 +6089,7 @@ function cleanSessionWorkspaceCache(sessionId, workdir) {
6037
6089
  return;
6038
6090
  }
6039
6091
  const dir = sessionDir(trimmedSessionId, workspaceApmDir(trimmedWorkdir));
6040
- if (existsSync20(dir)) {
6092
+ if (existsSync21(dir)) {
6041
6093
  rmSync4(dir, { recursive: true, force: true });
6042
6094
  console.log(`[apm] \u5DF2\u6E05\u7406\u4F1A\u8BDD\u7F13\u5B58 ${dir}`);
6043
6095
  } else {
@@ -6313,13 +6365,13 @@ ${JSON.stringify(event, null, 2)}
6313
6365
  }
6314
6366
 
6315
6367
  // src/commands/connect/agent-session-registry.ts
6316
- import { existsSync as existsSync21, mkdirSync as mkdirSync9, readFileSync as readFileSync16, writeFileSync as writeFileSync14 } from "node:fs";
6368
+ import { existsSync as existsSync22, mkdirSync as mkdirSync9, readFileSync as readFileSync16, writeFileSync as writeFileSync14 } from "node:fs";
6317
6369
  import { dirname as dirname6, resolve as resolve5 } from "node:path";
6318
6370
  function registryPath(workdir, sessionId) {
6319
6371
  return resolve5(workdir, ".apm", "sessions", sessionId, "cursor-agents.json");
6320
6372
  }
6321
6373
  function readRegistry(path19) {
6322
- if (!existsSync21(path19)) {
6374
+ if (!existsSync22(path19)) {
6323
6375
  return {};
6324
6376
  }
6325
6377
  try {
@@ -6791,15 +6843,15 @@ async function ensureMessageHasReply(cfg, sessionId, messageId, fallback) {
6791
6843
  }
6792
6844
 
6793
6845
  // src/commands/connect/cli-version-sync.ts
6794
- import { existsSync as existsSync22, readFileSync as readFileSync17, writeFileSync as writeFileSync15 } from "fs";
6795
- import { join as join17 } from "path";
6846
+ import { existsSync as existsSync23, readFileSync as readFileSync17, writeFileSync as writeFileSync15 } from "fs";
6847
+ import { join as join18 } from "path";
6796
6848
  var CLI_VERSION_FILE = ".cli-version.json";
6797
6849
  function manifestPath(apmDir) {
6798
- return join17(apmDir, CLI_VERSION_FILE);
6850
+ return join18(apmDir, CLI_VERSION_FILE);
6799
6851
  }
6800
6852
  function loadManifest4(apmDir) {
6801
6853
  const path19 = toFsPath(manifestPath(apmDir));
6802
- if (!existsSync22(path19)) {
6854
+ if (!existsSync23(path19)) {
6803
6855
  return null;
6804
6856
  }
6805
6857
  try {
@@ -7637,7 +7689,7 @@ import path15 from "node:path";
7637
7689
  import Docker from "dockerode";
7638
7690
 
7639
7691
  // src/commands/deploy/internal/backend-deploy/dockerode-client/connection-options.ts
7640
- import { existsSync as existsSync23, readFileSync as readFileSync18 } from "node:fs";
7692
+ import { existsSync as existsSync24, readFileSync as readFileSync18 } from "node:fs";
7641
7693
  import path12 from "node:path";
7642
7694
  function asOptionalTlsBuffer(value) {
7643
7695
  if (typeof value !== "string") {
@@ -7649,7 +7701,7 @@ function asOptionalTlsBuffer(value) {
7649
7701
  if (normalized === "") {
7650
7702
  return void 0;
7651
7703
  }
7652
- if (existsSync23(normalized)) {
7704
+ if (existsSync24(normalized)) {
7653
7705
  return readFileSync18(normalized);
7654
7706
  }
7655
7707
  const looksLikePath = /[\\/]/.test(normalized) || normalized.endsWith(".pem");
@@ -7860,7 +7912,7 @@ var DockerodeClient = class {
7860
7912
  var createDockerodeClient = (config) => new DockerodeClient(config);
7861
7913
 
7862
7914
  // src/commands/deploy/internal/backend-deploy/dockerode-client/env.ts
7863
- import { existsSync as existsSync24, readFileSync as readFileSync19, statSync as statSync10 } from "node:fs";
7915
+ import { existsSync as existsSync25, readFileSync as readFileSync19, statSync as statSync10 } from "node:fs";
7864
7916
  import path13 from "node:path";
7865
7917
  function stripSurroundingQuotes(value) {
7866
7918
  const t = value.trim();
@@ -7877,7 +7929,7 @@ function loadEnvFromFile(envFilePath) {
7877
7929
  return {};
7878
7930
  }
7879
7931
  const targetPath = path13.resolve(envFilePath);
7880
- if (!existsSync24(targetPath) || !statSync10(targetPath).isFile()) {
7932
+ if (!existsSync25(targetPath) || !statSync10(targetPath).isFile()) {
7881
7933
  return {};
7882
7934
  }
7883
7935
  const raw = readFileSync19(targetPath, "utf-8");
@@ -8051,12 +8103,12 @@ function dockerPushImage(params, cwd) {
8051
8103
  }
8052
8104
 
8053
8105
  // src/commands/deploy/internal/backend-deploy/resolve-dockerfile.ts
8054
- import { existsSync as existsSync25 } from "node:fs";
8106
+ import { existsSync as existsSync26 } from "node:fs";
8055
8107
  import path14 from "node:path";
8056
8108
  function resolveDockerBuildPaths(cwd) {
8057
8109
  const dockerfilePath = path14.join(cwd, "Dockerfile");
8058
8110
  Logger.info(`\u67E5\u627EDockerfile\u6587\u4EF6\uFF0C\u8DEF\u5F84: ${dockerfilePath}`);
8059
- if (!existsSync25(dockerfilePath)) {
8111
+ if (!existsSync26(dockerfilePath)) {
8060
8112
  throw new Error(`Dockerfile \u4E0D\u5B58\u5728\uFF1A${dockerfilePath}`);
8061
8113
  }
8062
8114
  Logger.info("\u2713 Dockerfile \u5B58\u5728");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-project-manage-cli",
3
- "version": "6.0.110",
3
+ "version": "6.0.111",
4
4
  "description": "命令行工具:后续用于调用平台后端 API 完成运维与自动化操作",
5
5
  "type": "module",
6
6
  "private": false,