ai-project-manage-cli 4.0.1 → 4.0.3

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 (3) hide show
  1. package/README.md +19 -0
  2. package/dist/index.js +33 -56
  3. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ ## 前置安装
2
+
3
+ ``
4
+
5
+ ## 安装
6
+
7
+ `npm install ai-project-manage-cli@latest`
8
+
9
+ ## 登录
10
+
11
+ `apm login --email=xxxxxxx@whbillion.com --password=123456 --server=http://192.168.10.217:3000`
12
+
13
+ ## 初始化
14
+
15
+ `apm init`
16
+
17
+ ## 连接服务器
18
+
19
+ `apm connect`
package/dist/index.js CHANGED
@@ -125,6 +125,10 @@ var requestConfig = {
125
125
  method: "POST",
126
126
  path: "/requirement-artifacts/create"
127
127
  }),
128
+ upsert: defineEndpoint({
129
+ method: "POST",
130
+ path: "/requirement-artifacts/upsert"
131
+ }),
128
132
  update: defineEndpoint({
129
133
  method: "POST",
130
134
  path: "/requirement-artifacts/update"
@@ -409,25 +413,6 @@ function* walkMarkdownFiles(dir) {
409
413
  yield full;
410
414
  }
411
415
  }
412
- async function deleteAllArtifactsForRequirement(api, requirementId) {
413
- const pageSize = 500;
414
- let page = 1;
415
- const rows = [];
416
- while (true) {
417
- const batch = await api.requirementArtifact.list({
418
- requirementId,
419
- page,
420
- pageSize
421
- });
422
- rows.push(...batch.items);
423
- if (batch.total === 0 || rows.length >= batch.total) break;
424
- page += 1;
425
- }
426
- for (const row of rows) {
427
- await api.requirementArtifact.delete({ artifactId: row.id });
428
- }
429
- return rows.length;
430
- }
431
416
  async function runUploadArtifact(requirementId, workspaceDir) {
432
417
  const cfg = await ensureLoggedConfig();
433
418
  const api = createApmApiClient(cfg);
@@ -439,32 +424,19 @@ async function runUploadArtifact(requirementId, workspaceDir) {
439
424
  );
440
425
  process.exit(1);
441
426
  }
442
- const deleted = await deleteAllArtifactsForRequirement(api, requirementId);
443
- console.log(`[apm] \u5DF2\u6E05\u7A7A\u9700\u6C42\u4EA7\u7269\u6587\u6863 ${deleted} \u6761`);
444
- const paths = [...walkMarkdownFiles(root)];
445
- let created = 0;
446
- let skipped = 0;
447
- for (const abs of paths) {
427
+ for (const abs of walkMarkdownFiles(root)) {
448
428
  const relPosix = toPosixRelative(root, abs);
449
- if (EXCLUDED_RELATIVE_PATHS.has(relPosix)) {
450
- skipped += 1;
451
- console.log(`[apm] \u8DF3\u8FC7\uFF08\u6392\u9664\u5217\u8868\uFF09: ${relPosix}`);
452
- continue;
453
- }
429
+ if (EXCLUDED_RELATIVE_PATHS.has(relPosix)) continue;
454
430
  const content = readFileSync3(abs, "utf8");
455
431
  const tag = artifactTagFromRelPath(relPosix);
456
- await api.requirementArtifact.create({
432
+ await api.requirementArtifact.upsert({
457
433
  requirementId,
458
434
  tag,
459
435
  fileName: relPosix,
460
436
  content
461
437
  });
462
- created += 1;
463
- console.log(`[apm] \u5DF2\u4E0A\u4F20\u4EA7\u7269: ${relPosix} (tag=${tag})`);
438
+ console.log(`[apm] \u5DF2\u540C\u6B65\u4EA7\u7269: ${relPosix}`);
464
439
  }
465
- console.log(
466
- `[apm] \u5B8C\u6210\uFF1A\u5220\u9664 ${deleted}\uFF0C\u65B0\u5EFA ${created}\uFF0C\u8DF3\u8FC7\uFF08\u6392\u9664\uFF09 ${skipped}\uFF0C\u5171\u626B\u63CF ${paths.length} \u4E2A Markdown \u6587\u4EF6`
467
- );
468
440
  }
469
441
 
470
442
  // src/commands/pull.ts
@@ -662,6 +634,11 @@ function runConnect(opts) {
662
634
  for await (const event of run.stream()) {
663
635
  if (event.type === "status") {
664
636
  console.log(`[Status]`, event.message || event.status);
637
+ if (event.status === "ERROR") {
638
+ console.log("===============================================");
639
+ console.log(JSON.stringify(event, null, 2));
640
+ console.log("===============================================");
641
+ }
665
642
  continue;
666
643
  }
667
644
  if (event.type === "assistant") {
@@ -960,7 +937,7 @@ async function runUpdateStatus(requirementId, status) {
960
937
  // src/commands/deploy/backend.ts
961
938
  import path5 from "node:path";
962
939
 
963
- // src/commands/deploy/lib/apm-config.ts
940
+ // src/commands/deploy/internal/apm-config.ts
964
941
  import { existsSync as existsSync3, readFileSync as readFileSync6 } from "node:fs";
965
942
  import { resolve as resolve4 } from "node:path";
966
943
  function loadApmConfig(options) {
@@ -1065,13 +1042,13 @@ function resolveFrontendDeployFromApmConfig(cfg) {
1065
1042
  };
1066
1043
  }
1067
1044
 
1068
- // src/commands/deploy/lib/backend-deploy/backend-deploy-workflow.ts
1045
+ // src/commands/deploy/internal/backend-deploy/backend-deploy-workflow.ts
1069
1046
  import path4 from "node:path";
1070
1047
 
1071
- // src/commands/deploy/lib/backend-deploy/dockerode-client/client.ts
1048
+ // src/commands/deploy/internal/backend-deploy/dockerode-client/client.ts
1072
1049
  import Docker from "dockerode";
1073
1050
 
1074
- // src/commands/deploy/lib/backend-deploy/dockerode-client/connection-options.ts
1051
+ // src/commands/deploy/internal/backend-deploy/dockerode-client/connection-options.ts
1075
1052
  import { existsSync as existsSync4, readFileSync as readFileSync7 } from "node:fs";
1076
1053
  import path from "node:path";
1077
1054
  function asOptionalTlsBuffer(value) {
@@ -1125,7 +1102,7 @@ function toDockerConnectionOptions(config) {
1125
1102
  return options;
1126
1103
  }
1127
1104
 
1128
- // src/commands/deploy/lib/backend-deploy/dockerode-client/container-inspect-format.ts
1105
+ // src/commands/deploy/internal/backend-deploy/dockerode-client/container-inspect-format.ts
1129
1106
  function formatPortMappings(inspectInfo) {
1130
1107
  const ports = inspectInfo?.NetworkSettings?.Ports;
1131
1108
  if (!ports || typeof ports !== "object") {
@@ -1146,7 +1123,7 @@ function formatPortMappings(inspectInfo) {
1146
1123
  return mappings.length > 0 ? mappings : void 0;
1147
1124
  }
1148
1125
 
1149
- // src/commands/deploy/lib/backend-deploy/dockerode-client/container-options.ts
1126
+ // src/commands/deploy/internal/backend-deploy/dockerode-client/container-options.ts
1150
1127
  function toContainerCreateOptions(input) {
1151
1128
  const hostConfig = {};
1152
1129
  let hasHostConfig = false;
@@ -1188,7 +1165,7 @@ function toContainerCreateOptions(input) {
1188
1165
  return payload;
1189
1166
  }
1190
1167
 
1191
- // src/commands/deploy/lib/backend-deploy/dockerode-client/client.ts
1168
+ // src/commands/deploy/internal/backend-deploy/dockerode-client/client.ts
1192
1169
  var DockerodeClient = class {
1193
1170
  client;
1194
1171
  constructor(config) {
@@ -1294,7 +1271,7 @@ var DockerodeClient = class {
1294
1271
  };
1295
1272
  var createDockerodeClient = (config) => new DockerodeClient(config);
1296
1273
 
1297
- // src/commands/deploy/lib/backend-deploy/dockerode-client/env.ts
1274
+ // src/commands/deploy/internal/backend-deploy/dockerode-client/env.ts
1298
1275
  import { existsSync as existsSync5, readFileSync as readFileSync8, statSync as statSync3 } from "node:fs";
1299
1276
  import path2 from "node:path";
1300
1277
  function stripSurroundingQuotes(value) {
@@ -1338,7 +1315,7 @@ function toEnvArray(env) {
1338
1315
  return Object.entries(env).map(([key, value]) => `${key}=${value}`);
1339
1316
  }
1340
1317
 
1341
- // src/commands/deploy/lib/backend-deploy/dockerode-client/ports.ts
1318
+ // src/commands/deploy/internal/backend-deploy/dockerode-client/ports.ts
1342
1319
  function parsePorts(ports) {
1343
1320
  if (!ports || ports.length === 0) {
1344
1321
  return {};
@@ -1368,7 +1345,7 @@ function parsePorts(ports) {
1368
1345
  };
1369
1346
  }
1370
1347
 
1371
- // src/commands/deploy/lib/backend-deploy/image-tag.ts
1348
+ // src/commands/deploy/internal/backend-deploy/image-tag.ts
1372
1349
  var DEPLOY_IMAGE_TAG = /^(?!\.|-)[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/;
1373
1350
  function assertDeployImageTag(tag) {
1374
1351
  const t = tag.trim();
@@ -1379,13 +1356,13 @@ function assertDeployImageTag(tag) {
1379
1356
  }
1380
1357
  }
1381
1358
 
1382
- // src/commands/deploy/lib/backend-deploy/local-docker-build.ts
1359
+ // src/commands/deploy/internal/backend-deploy/local-docker-build.ts
1383
1360
  import { platform } from "node:os";
1384
1361
 
1385
- // src/commands/deploy/lib/backend-deploy/command-runner.ts
1362
+ // src/commands/deploy/internal/backend-deploy/command-runner.ts
1386
1363
  import { execSync } from "child_process";
1387
1364
 
1388
- // src/commands/deploy/lib/backend-deploy/logger.ts
1365
+ // src/commands/deploy/internal/backend-deploy/logger.ts
1389
1366
  var Logger = class {
1390
1367
  static info(message) {
1391
1368
  console.log(`\x1B[36m[INFO]\x1B[0m ${message}`);
@@ -1401,7 +1378,7 @@ var Logger = class {
1401
1378
  }
1402
1379
  };
1403
1380
 
1404
- // src/commands/deploy/lib/backend-deploy/command-runner.ts
1381
+ // src/commands/deploy/internal/backend-deploy/command-runner.ts
1405
1382
  var CommandRunner = class {
1406
1383
  /**
1407
1384
  * 执行命令
@@ -1438,7 +1415,7 @@ var CommandRunner = class {
1438
1415
  }
1439
1416
  };
1440
1417
 
1441
- // src/commands/deploy/lib/backend-deploy/local-docker-build.ts
1418
+ // src/commands/deploy/internal/backend-deploy/local-docker-build.ts
1442
1419
  function dockerBuildPlatformFlags() {
1443
1420
  return platform() === "darwin" ? ["--platform", "linux/amd64"] : [];
1444
1421
  }
@@ -1451,7 +1428,7 @@ function buildDockerImageLocally(params, cwd) {
1451
1428
  Logger.info("\u2713 \u955C\u50CF\u6784\u5EFA\u6210\u529F");
1452
1429
  }
1453
1430
 
1454
- // src/commands/deploy/lib/backend-deploy/registry-login-push.ts
1431
+ // src/commands/deploy/internal/backend-deploy/registry-login-push.ts
1455
1432
  function dockerLoginPrivateRegistry(params, cwd) {
1456
1433
  const { registryUser, registryPassword, registryHost } = params;
1457
1434
  Logger.info("\u68C0\u67E5\u914D\u7F6E\u53C2\u6570...");
@@ -1485,7 +1462,7 @@ function dockerPushImage(params, cwd) {
1485
1462
  Logger.info("\u2713 \u955C\u50CF\u63A8\u9001\u6210\u529F");
1486
1463
  }
1487
1464
 
1488
- // src/commands/deploy/lib/backend-deploy/resolve-dockerfile.ts
1465
+ // src/commands/deploy/internal/backend-deploy/resolve-dockerfile.ts
1489
1466
  import { existsSync as existsSync6 } from "node:fs";
1490
1467
  import path3 from "node:path";
1491
1468
  function resolveDockerBuildPaths(cwd) {
@@ -1498,7 +1475,7 @@ function resolveDockerBuildPaths(cwd) {
1498
1475
  return dockerfilePath;
1499
1476
  }
1500
1477
 
1501
- // src/commands/deploy/lib/backend-deploy/backend-deploy-workflow.ts
1478
+ // src/commands/deploy/internal/backend-deploy/backend-deploy-workflow.ts
1502
1479
  var BackendDeployWorkflow = class {
1503
1480
  constructor(params) {
1504
1481
  this.params = params;
@@ -1619,7 +1596,7 @@ function registerDeployBackendCommands(program) {
1619
1596
  import { copyFile, readdir as readdir2, stat } from "node:fs/promises";
1620
1597
  import path7 from "node:path";
1621
1598
 
1622
- // src/commands/deploy/lib/load-apm-dotenv.ts
1599
+ // src/commands/deploy/internal/load-apm-dotenv.ts
1623
1600
  import { existsSync as existsSync7, readFileSync as readFileSync9 } from "node:fs";
1624
1601
  import { join as join8 } from "node:path";
1625
1602
  function loadApmDotEnvIfPresent() {
@@ -1653,7 +1630,7 @@ function loadApmDotEnvIfPresent() {
1653
1630
  }
1654
1631
  }
1655
1632
 
1656
- // src/commands/deploy/lib/minio.ts
1633
+ // src/commands/deploy/internal/minio.ts
1657
1634
  import { statSync as statSync4 } from "node:fs";
1658
1635
  import { readdir } from "node:fs/promises";
1659
1636
  import path6 from "node:path";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-project-manage-cli",
3
- "version": "4.0.1",
3
+ "version": "4.0.3",
4
4
  "description": "命令行工具:后续用于调用平台后端 API 完成运维与自动化操作",
5
5
  "type": "module",
6
6
  "private": false,