ai-project-manage-cli 7.1.28 → 7.1.29

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.
package/dist/index.js CHANGED
@@ -480,123 +480,33 @@ var init_minio = __esm({
480
480
  }
481
481
  });
482
482
 
483
- // src/commands/deploy/internal/deploy-artifact-minio.ts
484
- import { readFile as readFile2 } from "node:fs/promises";
485
- function formatDeployArtifactTimestamp(date = /* @__PURE__ */ new Date()) {
486
- const pad2 = (n) => String(n).padStart(2, "0");
487
- return `${date.getFullYear()}${pad2(date.getMonth() + 1)}${pad2(date.getDate())}${pad2(date.getHours())}${pad2(date.getMinutes())}${pad2(date.getSeconds())}`;
488
- }
489
- function sanitizeDeployProjectName(name) {
490
- const trimmed = name.trim().replace(/\\/g, "/");
491
- const base = trimmed.split("/").filter(Boolean).pop() ?? trimmed;
492
- try {
493
- return sanitizeRelativePath(base.replace(/[/\\:*?"<>|]/g, "_"));
494
- } catch {
495
- return "project";
496
- }
497
- }
498
- function buildDeployArtifactFileName(kind, projectName, timestamp = formatDeployArtifactTimestamp()) {
499
- const safeName = sanitizeDeployProjectName(projectName);
500
- const suffix = kind === "frontend" ? "dist.zip" : "jar.zip";
501
- return `${timestamp}-${safeName}.${suffix}`;
502
- }
503
- function buildDeployArtifactObjectKey(projectName, fileName) {
504
- const safeProject = sanitizeDeployProjectName(projectName);
505
- return `deploy/${safeProject}/${fileName}`;
506
- }
507
- function resolveDeploymentRunIdFromEnv() {
508
- const raw = process.env[APM_DEPLOYMENT_RUN_ID_ENV]?.trim();
509
- return raw || null;
510
- }
511
- async function fetchDeployArtifactStorage(api) {
512
- return api.cli.getDeployArtifactStorage(void 0);
513
- }
514
- async function uploadDeployArtifactZip(options) {
515
- const deploymentRunId = options.deploymentRunId ?? resolveDeploymentRunIdFromEnv();
516
- if (!deploymentRunId && !options.uploadWithoutRunId) {
517
- return null;
518
- }
519
- const cfg = await tryReadApmConfig();
520
- if (!cfg || !resolveApiKey(cfg)) {
521
- console.warn("[apm] \u672A\u767B\u5F55\uFF0C\u8DF3\u8FC7 MinIO \u90E8\u7F72\u4EA7\u7269\u5F52\u6863");
522
- return null;
523
- }
524
- const api = options.api ?? createApmApiClient(cfg);
525
- let storage;
526
- try {
527
- storage = await fetchDeployArtifactStorage(api);
528
- } catch (error) {
529
- const detail = error instanceof Error ? error.message : String(error);
530
- console.warn(`[apm] \u83B7\u53D6 MinIO \u914D\u7F6E\u5931\u8D25\uFF0C\u8DF3\u8FC7\u90E8\u7F72\u4EA7\u7269\u5F52\u6863: ${detail}`);
531
- return null;
532
- }
533
- const fileName = buildDeployArtifactFileName(
534
- options.kind,
535
- options.projectName,
536
- options.timestamp
537
- );
538
- const objectKey = buildDeployArtifactObjectKey(options.projectName, fileName);
539
- let body;
540
- try {
541
- body = await readFile2(options.zipPath);
542
- } catch (error) {
543
- const detail = error instanceof Error ? error.message : String(error);
544
- console.warn(`[apm] \u8BFB\u53D6\u90E8\u7F72\u4EA7\u7269 zip \u5931\u8D25\uFF0C\u8DF3\u8FC7 MinIO \u5F52\u6863: ${detail}`);
545
- return null;
546
- }
547
- try {
548
- const client = new MinioClient({
483
+ // src/commands/connect/apm-log-minio.ts
484
+ function createApmLogMinioClient() {
485
+ const storage = APM_LOG_MINIO_CONFIG;
486
+ return {
487
+ client: new MinioClient({
549
488
  endPoint: storage.endpoint,
550
489
  port: storage.port,
551
490
  useSSL: storage.useSsl,
552
491
  accessKey: storage.accessKey,
553
492
  secretKey: storage.secretKey
554
- });
555
- await client.ensureBucket(storage.bucket);
556
- await client.putObject(storage.bucket, objectKey, body, {
557
- "Content-Type": "application/zip"
558
- });
559
- console.error(
560
- `[apm] \u672C\u5730\u76F4\u4F20 MinIO\uFF08\u4E0D\u7ECF\u5E73\u53F0\u670D\u52A1\u5668\uFF09: ${storage.endpoint}:${storage.port}/${storage.bucket}/${objectKey} (${(body.length / 1024 / 1024).toFixed(
561
- 2
562
- )} MB)`
563
- );
564
- } catch (error) {
565
- const detail = error instanceof Error ? error.message : String(error);
566
- console.warn(`[apm] MinIO \u90E8\u7F72\u4EA7\u7269\u5F52\u6863\u5931\u8D25: ${detail}`);
567
- return null;
568
- }
569
- if (deploymentRunId) {
570
- try {
571
- await api.cli.attachTaskDeploymentArtifact({
572
- id: deploymentRunId,
573
- artifactObjectKey: objectKey,
574
- artifactFileName: fileName
575
- });
576
- console.error(
577
- `[apm] \u5DF2\u7ED1\u5B9A\u90E8\u7F72\u4EA7\u7269\u5230\u8BB0\u5F55 id=${deploymentRunId} file=${fileName}`
578
- );
579
- } catch (error) {
580
- const detail = error instanceof Error ? error.message : String(error);
581
- console.warn(`[apm] \u7ED1\u5B9A\u90E8\u7F72\u4EA7\u7269\u5230\u8BB0\u5F55\u5931\u8D25: ${detail}`);
582
- return null;
583
- }
584
- }
585
- return {
586
- objectKey,
587
- fileName,
493
+ }),
588
494
  bucket: storage.bucket
589
495
  };
590
496
  }
591
- var APM_DEPLOYMENT_RUN_ID_ENV;
592
- var init_deploy_artifact_minio = __esm({
593
- "src/commands/deploy/internal/deploy-artifact-minio.ts"() {
497
+ var APM_LOG_MINIO_CONFIG;
498
+ var init_apm_log_minio = __esm({
499
+ "src/commands/connect/apm-log-minio.ts"() {
594
500
  "use strict";
595
- init_client();
596
- init_config();
597
- init_minio();
598
501
  init_minio();
599
- APM_DEPLOYMENT_RUN_ID_ENV = "APM_DEPLOYMENT_RUN_ID";
502
+ APM_LOG_MINIO_CONFIG = {
503
+ endpoint: "objectstorageapi.gzg.sealos.run",
504
+ port: 443,
505
+ useSsl: true,
506
+ accessKey: "428hqav4",
507
+ secretKey: "68b8srk4vdbjdhlc",
508
+ bucket: "428hqav4-apm-log"
509
+ };
600
510
  }
601
511
  });
602
512
 
@@ -719,8 +629,7 @@ var init_webide_terminal_registry = __esm({
719
629
  "src/commands/connect/webide-terminal-registry.ts"() {
720
630
  "use strict";
721
631
  init_client();
722
- init_deploy_artifact_minio();
723
- init_minio();
632
+ init_apm_log_minio();
724
633
  execFileAsync3 = promisify3(execFile3);
725
634
  WEBIDE_TERMINAL_LINES_PER_CHUNK = 50;
726
635
  SYNC_INTERVAL_MS = 400;
@@ -738,17 +647,9 @@ var init_webide_terminal_registry = __esm({
738
647
  bucket = "";
739
648
  async ensureMinio() {
740
649
  if (this.minio) return;
741
- const storage = await fetchDeployArtifactStorage(
742
- createApmApiClient(this.cfg)
743
- );
744
- this.minio = new MinioClient({
745
- endPoint: storage.endpoint,
746
- port: storage.port,
747
- useSSL: storage.useSsl,
748
- accessKey: storage.accessKey,
749
- secretKey: storage.secretKey
750
- });
751
- this.bucket = storage.bucket;
650
+ const created = createApmLogMinioClient();
651
+ this.minio = created.client;
652
+ this.bucket = created.bucket;
752
653
  await this.minio.ensureBucket(this.bucket);
753
654
  }
754
655
  listLocal(taskId) {
@@ -4374,11 +4275,124 @@ var DeployExecutionError = class extends Error {
4374
4275
  };
4375
4276
 
4376
4277
  // src/commands/deploy/deploy-debug-log.ts
4377
- init_deploy_artifact_minio();
4378
4278
  import { spawnSync as spawnSync4 } from "node:child_process";
4379
4279
  import { existsSync as existsSync17 } from "node:fs";
4380
4280
  import { dirname as dirname6, join as join18 } from "node:path";
4381
4281
 
4282
+ // src/commands/deploy/internal/deploy-artifact-minio.ts
4283
+ init_client();
4284
+ init_config();
4285
+ init_minio();
4286
+ init_minio();
4287
+ import { readFile as readFile2 } from "node:fs/promises";
4288
+ var APM_DEPLOYMENT_RUN_ID_ENV = "APM_DEPLOYMENT_RUN_ID";
4289
+ function formatDeployArtifactTimestamp(date = /* @__PURE__ */ new Date()) {
4290
+ const pad2 = (n) => String(n).padStart(2, "0");
4291
+ return `${date.getFullYear()}${pad2(date.getMonth() + 1)}${pad2(date.getDate())}${pad2(date.getHours())}${pad2(date.getMinutes())}${pad2(date.getSeconds())}`;
4292
+ }
4293
+ function sanitizeDeployProjectName(name) {
4294
+ const trimmed = name.trim().replace(/\\/g, "/");
4295
+ const base = trimmed.split("/").filter(Boolean).pop() ?? trimmed;
4296
+ try {
4297
+ return sanitizeRelativePath(base.replace(/[/\\:*?"<>|]/g, "_"));
4298
+ } catch {
4299
+ return "project";
4300
+ }
4301
+ }
4302
+ function buildDeployArtifactFileName(kind, projectName, timestamp = formatDeployArtifactTimestamp()) {
4303
+ const safeName = sanitizeDeployProjectName(projectName);
4304
+ const suffix = kind === "frontend" ? "dist.zip" : "jar.zip";
4305
+ return `${timestamp}-${safeName}.${suffix}`;
4306
+ }
4307
+ function buildDeployArtifactObjectKey(projectName, fileName) {
4308
+ const safeProject = sanitizeDeployProjectName(projectName);
4309
+ return `deploy/${safeProject}/${fileName}`;
4310
+ }
4311
+ function resolveDeploymentRunIdFromEnv() {
4312
+ const raw = process.env[APM_DEPLOYMENT_RUN_ID_ENV]?.trim();
4313
+ return raw || null;
4314
+ }
4315
+ async function fetchDeployArtifactStorage(api) {
4316
+ return api.cli.getDeployArtifactStorage(void 0);
4317
+ }
4318
+ async function uploadDeployArtifactZip(options) {
4319
+ const deploymentRunId = options.deploymentRunId ?? resolveDeploymentRunIdFromEnv();
4320
+ if (!deploymentRunId && !options.uploadWithoutRunId) {
4321
+ return null;
4322
+ }
4323
+ const cfg = await tryReadApmConfig();
4324
+ if (!cfg || !resolveApiKey(cfg)) {
4325
+ console.warn("[apm] \u672A\u767B\u5F55\uFF0C\u8DF3\u8FC7 MinIO \u90E8\u7F72\u4EA7\u7269\u5F52\u6863");
4326
+ return null;
4327
+ }
4328
+ const api = options.api ?? createApmApiClient(cfg);
4329
+ let storage;
4330
+ try {
4331
+ storage = await fetchDeployArtifactStorage(api);
4332
+ } catch (error) {
4333
+ const detail = error instanceof Error ? error.message : String(error);
4334
+ console.warn(`[apm] \u83B7\u53D6 MinIO \u914D\u7F6E\u5931\u8D25\uFF0C\u8DF3\u8FC7\u90E8\u7F72\u4EA7\u7269\u5F52\u6863: ${detail}`);
4335
+ return null;
4336
+ }
4337
+ const fileName = buildDeployArtifactFileName(
4338
+ options.kind,
4339
+ options.projectName,
4340
+ options.timestamp
4341
+ );
4342
+ const objectKey = buildDeployArtifactObjectKey(options.projectName, fileName);
4343
+ let body;
4344
+ try {
4345
+ body = await readFile2(options.zipPath);
4346
+ } catch (error) {
4347
+ const detail = error instanceof Error ? error.message : String(error);
4348
+ console.warn(`[apm] \u8BFB\u53D6\u90E8\u7F72\u4EA7\u7269 zip \u5931\u8D25\uFF0C\u8DF3\u8FC7 MinIO \u5F52\u6863: ${detail}`);
4349
+ return null;
4350
+ }
4351
+ try {
4352
+ const client = new MinioClient({
4353
+ endPoint: storage.endpoint,
4354
+ port: storage.port,
4355
+ useSSL: storage.useSsl,
4356
+ accessKey: storage.accessKey,
4357
+ secretKey: storage.secretKey
4358
+ });
4359
+ await client.ensureBucket(storage.bucket);
4360
+ await client.putObject(storage.bucket, objectKey, body, {
4361
+ "Content-Type": "application/zip"
4362
+ });
4363
+ console.error(
4364
+ `[apm] \u672C\u5730\u76F4\u4F20 MinIO\uFF08\u4E0D\u7ECF\u5E73\u53F0\u670D\u52A1\u5668\uFF09: ${storage.endpoint}:${storage.port}/${storage.bucket}/${objectKey} (${(body.length / 1024 / 1024).toFixed(
4365
+ 2
4366
+ )} MB)`
4367
+ );
4368
+ } catch (error) {
4369
+ const detail = error instanceof Error ? error.message : String(error);
4370
+ console.warn(`[apm] MinIO \u90E8\u7F72\u4EA7\u7269\u5F52\u6863\u5931\u8D25: ${detail}`);
4371
+ return null;
4372
+ }
4373
+ if (deploymentRunId) {
4374
+ try {
4375
+ await api.cli.attachTaskDeploymentArtifact({
4376
+ id: deploymentRunId,
4377
+ artifactObjectKey: objectKey,
4378
+ artifactFileName: fileName
4379
+ });
4380
+ console.error(
4381
+ `[apm] \u5DF2\u7ED1\u5B9A\u90E8\u7F72\u4EA7\u7269\u5230\u8BB0\u5F55 id=${deploymentRunId} file=${fileName}`
4382
+ );
4383
+ } catch (error) {
4384
+ const detail = error instanceof Error ? error.message : String(error);
4385
+ console.warn(`[apm] \u7ED1\u5B9A\u90E8\u7F72\u4EA7\u7269\u5230\u8BB0\u5F55\u5931\u8D25: ${detail}`);
4386
+ return null;
4387
+ }
4388
+ }
4389
+ return {
4390
+ objectKey,
4391
+ fileName,
4392
+ bucket: storage.bucket
4393
+ };
4394
+ }
4395
+
4382
4396
  // src/commands/deploy/internal/deploy-shell-env.ts
4383
4397
  import { spawnSync as spawnSync3 } from "node:child_process";
4384
4398
  import { existsSync as existsSync16 } from "node:fs";
@@ -5527,7 +5541,6 @@ function runDeployShellCommand(command, cwd, captureOutput) {
5527
5541
 
5528
5542
  // src/commands/deploy/internal/wisdom-backend/index.ts
5529
5543
  import path9 from "node:path";
5530
- init_deploy_artifact_minio();
5531
5544
 
5532
5545
  // src/commands/deploy/internal/wisdom-backend/jar-incremental.ts
5533
5546
  import {
@@ -5596,7 +5609,6 @@ import SftpClient from "ssh2-sftp-client";
5596
5609
  import { readdir as readdir2, readFile as readFile3, unlink, writeFile } from "node:fs/promises";
5597
5610
  import path3 from "node:path";
5598
5611
  import JSZip from "jszip";
5599
- init_deploy_artifact_minio();
5600
5612
  init_minio();
5601
5613
  async function addDirToZip(dir, zipFolder) {
5602
5614
  const entries = await readdir2(dir, { withFileTypes: true });
@@ -5686,7 +5698,6 @@ async function packDirectoryWithMinioArchive(input) {
5686
5698
  }
5687
5699
 
5688
5700
  // src/commands/deploy/internal/wisdom-sftp.ts
5689
- init_deploy_artifact_minio();
5690
5701
  var SFTP_UPLOAD_MAX_ATTEMPTS = 3;
5691
5702
  var SFTP_FAST_PUT_OPTIONS = {
5692
5703
  chunkSize: 64 * 1024,
@@ -6896,9 +6907,6 @@ function printDeployExecutionError(error) {
6896
6907
  console.error(error.message);
6897
6908
  }
6898
6909
 
6899
- // src/commands/deploy/platform/deploy-run-coordinator.ts
6900
- init_deploy_artifact_minio();
6901
-
6902
6910
  // src/commands/deploy/platform/deploy-console-capture.ts
6903
6911
  function captureDeployConsole(logSyncer) {
6904
6912
  const chunks = [];
@@ -7428,14 +7436,34 @@ var EventSession = class {
7428
7436
  });
7429
7437
  this.markDirty(this.events.length - 1);
7430
7438
  }
7431
- /** CLI 本地准备步骤(工作区/分支/文档等),写入日志供 WebIDE 查看 */
7439
+ /**
7440
+ * CLI 本地准备步骤(工作区/分支/文档等),写入日志供 WebIDE 查看。
7441
+ * 同名 step 原地更新(进行中→完成合并为一行),终态时写入 durationMs。
7442
+ */
7432
7443
  addCliStep(step, text, status = "ok") {
7444
+ const existingIndex = this.events.findIndex(
7445
+ (e) => e.type === "cli_step" && e.step === step
7446
+ );
7447
+ const now = Date.now();
7448
+ if (existingIndex >= 0) {
7449
+ const existing = this.events[existingIndex];
7450
+ existing.status = status;
7451
+ existing.text = text;
7452
+ if (status !== "running") {
7453
+ const startedAt = typeof existing.at === "string" ? Date.parse(existing.at) : NaN;
7454
+ if (Number.isFinite(startedAt)) {
7455
+ existing.durationMs = Math.max(0, now - startedAt);
7456
+ }
7457
+ }
7458
+ this.markDirty(existingIndex);
7459
+ return;
7460
+ }
7433
7461
  this.events.push({
7434
7462
  type: "cli_step",
7435
7463
  step,
7436
7464
  status,
7437
7465
  text,
7438
- at: (/* @__PURE__ */ new Date()).toISOString()
7466
+ at: new Date(now).toISOString()
7439
7467
  });
7440
7468
  this.markDirty(this.events.length - 1);
7441
7469
  }
@@ -1362,14 +1362,34 @@ var EventSession = class {
1362
1362
  });
1363
1363
  this.markDirty(this.events.length - 1);
1364
1364
  }
1365
- /** CLI 本地准备步骤(工作区/分支/文档等),写入日志供 WebIDE 查看 */
1365
+ /**
1366
+ * CLI 本地准备步骤(工作区/分支/文档等),写入日志供 WebIDE 查看。
1367
+ * 同名 step 原地更新(进行中→完成合并为一行),终态时写入 durationMs。
1368
+ */
1366
1369
  addCliStep(step, text, status = "ok") {
1370
+ const existingIndex = this.events.findIndex(
1371
+ (e) => e.type === "cli_step" && e.step === step
1372
+ );
1373
+ const now = Date.now();
1374
+ if (existingIndex >= 0) {
1375
+ const existing = this.events[existingIndex];
1376
+ existing.status = status;
1377
+ existing.text = text;
1378
+ if (status !== "running") {
1379
+ const startedAt = typeof existing.at === "string" ? Date.parse(existing.at) : NaN;
1380
+ if (Number.isFinite(startedAt)) {
1381
+ existing.durationMs = Math.max(0, now - startedAt);
1382
+ }
1383
+ }
1384
+ this.markDirty(existingIndex);
1385
+ return;
1386
+ }
1367
1387
  this.events.push({
1368
1388
  type: "cli_step",
1369
1389
  step,
1370
1390
  status,
1371
1391
  text,
1372
- at: (/* @__PURE__ */ new Date()).toISOString()
1392
+ at: new Date(now).toISOString()
1373
1393
  });
1374
1394
  this.markDirty(this.events.length - 1);
1375
1395
  }
@@ -2683,9 +2703,27 @@ var MinioClient = class {
2683
2703
  }
2684
2704
  };
2685
2705
 
2686
- // src/commands/deploy/internal/deploy-artifact-minio.ts
2687
- async function fetchDeployArtifactStorage(api) {
2688
- return api.cli.getDeployArtifactStorage(void 0);
2706
+ // src/commands/connect/apm-log-minio.ts
2707
+ var APM_LOG_MINIO_CONFIG = {
2708
+ endpoint: "objectstorageapi.gzg.sealos.run",
2709
+ port: 443,
2710
+ useSsl: true,
2711
+ accessKey: "428hqav4",
2712
+ secretKey: "68b8srk4vdbjdhlc",
2713
+ bucket: "428hqav4-apm-log"
2714
+ };
2715
+ function createApmLogMinioClient() {
2716
+ const storage = APM_LOG_MINIO_CONFIG;
2717
+ return {
2718
+ client: new MinioClient({
2719
+ endPoint: storage.endpoint,
2720
+ port: storage.port,
2721
+ useSSL: storage.useSsl,
2722
+ accessKey: storage.accessKey,
2723
+ secretKey: storage.secretKey
2724
+ }),
2725
+ bucket: storage.bucket
2726
+ };
2689
2727
  }
2690
2728
 
2691
2729
  // src/commands/connect/webide-message-log.ts
@@ -2728,15 +2766,9 @@ function createThrottledWebIdeMessageLogSync(cfg, ctx, onError, options) {
2728
2766
  let firstLogNotified = false;
2729
2767
  const ensureMinio = async () => {
2730
2768
  if (minio) return;
2731
- const storage = await fetchDeployArtifactStorage(createApmApiClient(cfg));
2732
- minio = new MinioClient({
2733
- endPoint: storage.endpoint,
2734
- port: storage.port,
2735
- useSSL: storage.useSsl,
2736
- accessKey: storage.accessKey,
2737
- secretKey: storage.secretKey
2738
- });
2739
- bucket = storage.bucket;
2769
+ const created = createApmLogMinioClient();
2770
+ minio = created.client;
2771
+ bucket = created.bucket;
2740
2772
  await minio.ensureBucket(bucket);
2741
2773
  };
2742
2774
  const notifyFirstLog = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-project-manage-cli",
3
- "version": "7.1.28",
3
+ "version": "7.1.29",
4
4
  "description": "命令行工具:后续用于调用平台后端 API 完成运维与自动化操作",
5
5
  "type": "module",
6
6
  "private": false,