ai-project-manage-cli 3.0.24 → 4.0.2
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/README.md +19 -0
- package/dist/index.js +51 -96
- 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
|
@@ -114,14 +114,6 @@ var requestConfig = {
|
|
|
114
114
|
updateDevStatus: defineEndpoint({
|
|
115
115
|
method: "POST",
|
|
116
116
|
path: "/cli/requirements/update-dev-status"
|
|
117
|
-
}),
|
|
118
|
-
updateTaskStatus: defineEndpoint({
|
|
119
|
-
method: "POST",
|
|
120
|
-
path: "/cli/requirements/update-task-status"
|
|
121
|
-
}),
|
|
122
|
-
updateTaskAgentId: defineEndpoint({
|
|
123
|
-
method: "POST",
|
|
124
|
-
path: "/cli/requirements/update-task-agent-id"
|
|
125
117
|
})
|
|
126
118
|
},
|
|
127
119
|
requirementArtifact: {
|
|
@@ -133,6 +125,10 @@ var requestConfig = {
|
|
|
133
125
|
method: "POST",
|
|
134
126
|
path: "/requirement-artifacts/create"
|
|
135
127
|
}),
|
|
128
|
+
upsert: defineEndpoint({
|
|
129
|
+
method: "POST",
|
|
130
|
+
path: "/requirement-artifacts/upsert"
|
|
131
|
+
}),
|
|
136
132
|
update: defineEndpoint({
|
|
137
133
|
method: "POST",
|
|
138
134
|
path: "/requirement-artifacts/update"
|
|
@@ -141,6 +137,18 @@ var requestConfig = {
|
|
|
141
137
|
method: "POST",
|
|
142
138
|
path: "/requirement-artifacts/delete"
|
|
143
139
|
})
|
|
140
|
+
},
|
|
141
|
+
spaceWorkflow: {
|
|
142
|
+
aiStartNode: defineEndpoint({
|
|
143
|
+
method: "POST",
|
|
144
|
+
path: "/space-workflows/ai-start-node"
|
|
145
|
+
}),
|
|
146
|
+
aiConfirmNode: defineEndpoint(
|
|
147
|
+
{
|
|
148
|
+
method: "POST",
|
|
149
|
+
path: "/space-workflows/ai-confirm-node"
|
|
150
|
+
}
|
|
151
|
+
)
|
|
144
152
|
}
|
|
145
153
|
};
|
|
146
154
|
|
|
@@ -405,25 +413,6 @@ function* walkMarkdownFiles(dir) {
|
|
|
405
413
|
yield full;
|
|
406
414
|
}
|
|
407
415
|
}
|
|
408
|
-
async function deleteAllArtifactsForRequirement(api, requirementId) {
|
|
409
|
-
const pageSize = 500;
|
|
410
|
-
let page = 1;
|
|
411
|
-
const rows = [];
|
|
412
|
-
while (true) {
|
|
413
|
-
const batch = await api.requirementArtifact.list({
|
|
414
|
-
requirementId,
|
|
415
|
-
page,
|
|
416
|
-
pageSize
|
|
417
|
-
});
|
|
418
|
-
rows.push(...batch.items);
|
|
419
|
-
if (batch.total === 0 || rows.length >= batch.total) break;
|
|
420
|
-
page += 1;
|
|
421
|
-
}
|
|
422
|
-
for (const row of rows) {
|
|
423
|
-
await api.requirementArtifact.delete({ artifactId: row.id });
|
|
424
|
-
}
|
|
425
|
-
return rows.length;
|
|
426
|
-
}
|
|
427
416
|
async function runUploadArtifact(requirementId, workspaceDir) {
|
|
428
417
|
const cfg = await ensureLoggedConfig();
|
|
429
418
|
const api = createApmApiClient(cfg);
|
|
@@ -435,32 +424,19 @@ async function runUploadArtifact(requirementId, workspaceDir) {
|
|
|
435
424
|
);
|
|
436
425
|
process.exit(1);
|
|
437
426
|
}
|
|
438
|
-
const
|
|
439
|
-
console.log(`[apm] \u5DF2\u6E05\u7A7A\u9700\u6C42\u4EA7\u7269\u6587\u6863 ${deleted} \u6761`);
|
|
440
|
-
const paths = [...walkMarkdownFiles(root)];
|
|
441
|
-
let created = 0;
|
|
442
|
-
let skipped = 0;
|
|
443
|
-
for (const abs of paths) {
|
|
427
|
+
for (const abs of walkMarkdownFiles(root)) {
|
|
444
428
|
const relPosix = toPosixRelative(root, abs);
|
|
445
|
-
if (EXCLUDED_RELATIVE_PATHS.has(relPosix))
|
|
446
|
-
skipped += 1;
|
|
447
|
-
console.log(`[apm] \u8DF3\u8FC7\uFF08\u6392\u9664\u5217\u8868\uFF09: ${relPosix}`);
|
|
448
|
-
continue;
|
|
449
|
-
}
|
|
429
|
+
if (EXCLUDED_RELATIVE_PATHS.has(relPosix)) continue;
|
|
450
430
|
const content = readFileSync3(abs, "utf8");
|
|
451
431
|
const tag = artifactTagFromRelPath(relPosix);
|
|
452
|
-
await api.requirementArtifact.
|
|
432
|
+
await api.requirementArtifact.upsert({
|
|
453
433
|
requirementId,
|
|
454
434
|
tag,
|
|
455
435
|
fileName: relPosix,
|
|
456
436
|
content
|
|
457
437
|
});
|
|
458
|
-
|
|
459
|
-
console.log(`[apm] \u5DF2\u4E0A\u4F20\u4EA7\u7269: ${relPosix} (tag=${tag})`);
|
|
438
|
+
console.log(`[apm] \u5DF2\u540C\u6B65\u4EA7\u7269: ${relPosix}`);
|
|
460
439
|
}
|
|
461
|
-
console.log(
|
|
462
|
-
`[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`
|
|
463
|
-
);
|
|
464
440
|
}
|
|
465
441
|
|
|
466
442
|
// src/commands/pull.ts
|
|
@@ -501,14 +477,6 @@ function unknownArrayToXml(rootName, itemName, items) {
|
|
|
501
477
|
lines.push(`</${rootName}>`, "");
|
|
502
478
|
return lines.join("\n");
|
|
503
479
|
}
|
|
504
|
-
function tasksForStatusYaml(tasks) {
|
|
505
|
-
return tasks.map((t) => ({
|
|
506
|
-
id: t.id,
|
|
507
|
-
title: t.title,
|
|
508
|
-
status: t.status,
|
|
509
|
-
executor: t.executorType
|
|
510
|
-
}));
|
|
511
|
-
}
|
|
512
480
|
function escapeForCdata(text) {
|
|
513
481
|
return text.replace(/\]\]>/g, "]]]]><![CDATA[>");
|
|
514
482
|
}
|
|
@@ -547,8 +515,7 @@ async function runPull(requirementId, workspaceDir) {
|
|
|
547
515
|
id: req2.id,
|
|
548
516
|
status: req2.status,
|
|
549
517
|
title: req2.title,
|
|
550
|
-
env: req2.envName || ""
|
|
551
|
-
tasks: tasksForStatusYaml(data.tasks ?? [])
|
|
518
|
+
env: req2.envName || ""
|
|
552
519
|
},
|
|
553
520
|
{ lineWidth: 0 }
|
|
554
521
|
);
|
|
@@ -635,6 +602,7 @@ function runConnect(opts) {
|
|
|
635
602
|
const payload = msg.payload;
|
|
636
603
|
const apmRoot = join5(payload.cwd, ".apm");
|
|
637
604
|
console.log("[apm] ROOT:", apmRoot);
|
|
605
|
+
console.log("[apm] workflow node:", payload.nodeId);
|
|
638
606
|
try {
|
|
639
607
|
await runPull(payload.requirementId, apmRoot);
|
|
640
608
|
} catch (pullErr) {
|
|
@@ -656,23 +624,14 @@ function runConnect(opts) {
|
|
|
656
624
|
requirementId: payload.requirementId,
|
|
657
625
|
status: "WORKING"
|
|
658
626
|
});
|
|
659
|
-
await api.
|
|
660
|
-
taskId: payload.taskId,
|
|
627
|
+
await api.spaceWorkflow.aiStartNode({
|
|
661
628
|
requirementId: payload.requirementId,
|
|
629
|
+
nodeId: payload.nodeId,
|
|
662
630
|
agentId: agent.agentId
|
|
663
631
|
});
|
|
664
|
-
let IN_PROGRESS = false;
|
|
665
632
|
const session = new EventSession(payload.prompt);
|
|
666
633
|
const run = await agent.send(payload.prompt);
|
|
667
634
|
for await (const event of run.stream()) {
|
|
668
|
-
if (!IN_PROGRESS) {
|
|
669
|
-
await api.cliRequirements.updateTaskStatus({
|
|
670
|
-
taskId: payload.taskId,
|
|
671
|
-
requirementId: payload.requirementId,
|
|
672
|
-
status: "IN_PROGRESS"
|
|
673
|
-
});
|
|
674
|
-
IN_PROGRESS = true;
|
|
675
|
-
}
|
|
676
635
|
if (event.type === "status") {
|
|
677
636
|
console.log(`[Status]`, event.message || event.status);
|
|
678
637
|
continue;
|
|
@@ -707,11 +666,6 @@ function runConnect(opts) {
|
|
|
707
666
|
}
|
|
708
667
|
console.log("\u672A\u77E5\u4E8B\u4EF6:", JSON.stringify(event, null, 2));
|
|
709
668
|
}
|
|
710
|
-
await api.cliRequirements.updateTaskStatus({
|
|
711
|
-
taskId: payload.taskId,
|
|
712
|
-
requirementId: payload.requirementId,
|
|
713
|
-
status: "PENDING_ACCEPTANCE"
|
|
714
|
-
});
|
|
715
669
|
await api.cliRequirements.updateDevStatus({
|
|
716
670
|
requirementId: payload.requirementId,
|
|
717
671
|
status: "IDLE"
|
|
@@ -724,12 +678,13 @@ function runConnect(opts) {
|
|
|
724
678
|
console.error("[apm] apm upload-artifact \u5931\u8D25:", pullErr);
|
|
725
679
|
throw pullErr;
|
|
726
680
|
}
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
681
|
+
const confirmResult = await api.spaceWorkflow.aiConfirmNode({
|
|
682
|
+
requirementId: payload.requirementId,
|
|
683
|
+
nodeId: payload.nodeId
|
|
684
|
+
});
|
|
685
|
+
console.log("[apm] \u5DE5\u4F5C\u6D41\u8282\u70B9\u72B6\u6001:", confirmResult.nodeStatus);
|
|
686
|
+
} catch {
|
|
687
|
+
console.error("[apm] \u65E0\u6CD5\u89E3\u6790 WebSocket \u6D88\u606F:", text);
|
|
733
688
|
}
|
|
734
689
|
});
|
|
735
690
|
ws.on("error", (err) => {
|
|
@@ -977,7 +932,7 @@ async function runUpdateStatus(requirementId, status) {
|
|
|
977
932
|
// src/commands/deploy/backend.ts
|
|
978
933
|
import path5 from "node:path";
|
|
979
934
|
|
|
980
|
-
// src/commands/deploy/
|
|
935
|
+
// src/commands/deploy/internal/apm-config.ts
|
|
981
936
|
import { existsSync as existsSync3, readFileSync as readFileSync6 } from "node:fs";
|
|
982
937
|
import { resolve as resolve4 } from "node:path";
|
|
983
938
|
function loadApmConfig(options) {
|
|
@@ -1082,13 +1037,13 @@ function resolveFrontendDeployFromApmConfig(cfg) {
|
|
|
1082
1037
|
};
|
|
1083
1038
|
}
|
|
1084
1039
|
|
|
1085
|
-
// src/commands/deploy/
|
|
1040
|
+
// src/commands/deploy/internal/backend-deploy/backend-deploy-workflow.ts
|
|
1086
1041
|
import path4 from "node:path";
|
|
1087
1042
|
|
|
1088
|
-
// src/commands/deploy/
|
|
1043
|
+
// src/commands/deploy/internal/backend-deploy/dockerode-client/client.ts
|
|
1089
1044
|
import Docker from "dockerode";
|
|
1090
1045
|
|
|
1091
|
-
// src/commands/deploy/
|
|
1046
|
+
// src/commands/deploy/internal/backend-deploy/dockerode-client/connection-options.ts
|
|
1092
1047
|
import { existsSync as existsSync4, readFileSync as readFileSync7 } from "node:fs";
|
|
1093
1048
|
import path from "node:path";
|
|
1094
1049
|
function asOptionalTlsBuffer(value) {
|
|
@@ -1142,7 +1097,7 @@ function toDockerConnectionOptions(config) {
|
|
|
1142
1097
|
return options;
|
|
1143
1098
|
}
|
|
1144
1099
|
|
|
1145
|
-
// src/commands/deploy/
|
|
1100
|
+
// src/commands/deploy/internal/backend-deploy/dockerode-client/container-inspect-format.ts
|
|
1146
1101
|
function formatPortMappings(inspectInfo) {
|
|
1147
1102
|
const ports = inspectInfo?.NetworkSettings?.Ports;
|
|
1148
1103
|
if (!ports || typeof ports !== "object") {
|
|
@@ -1163,7 +1118,7 @@ function formatPortMappings(inspectInfo) {
|
|
|
1163
1118
|
return mappings.length > 0 ? mappings : void 0;
|
|
1164
1119
|
}
|
|
1165
1120
|
|
|
1166
|
-
// src/commands/deploy/
|
|
1121
|
+
// src/commands/deploy/internal/backend-deploy/dockerode-client/container-options.ts
|
|
1167
1122
|
function toContainerCreateOptions(input) {
|
|
1168
1123
|
const hostConfig = {};
|
|
1169
1124
|
let hasHostConfig = false;
|
|
@@ -1205,7 +1160,7 @@ function toContainerCreateOptions(input) {
|
|
|
1205
1160
|
return payload;
|
|
1206
1161
|
}
|
|
1207
1162
|
|
|
1208
|
-
// src/commands/deploy/
|
|
1163
|
+
// src/commands/deploy/internal/backend-deploy/dockerode-client/client.ts
|
|
1209
1164
|
var DockerodeClient = class {
|
|
1210
1165
|
client;
|
|
1211
1166
|
constructor(config) {
|
|
@@ -1311,7 +1266,7 @@ var DockerodeClient = class {
|
|
|
1311
1266
|
};
|
|
1312
1267
|
var createDockerodeClient = (config) => new DockerodeClient(config);
|
|
1313
1268
|
|
|
1314
|
-
// src/commands/deploy/
|
|
1269
|
+
// src/commands/deploy/internal/backend-deploy/dockerode-client/env.ts
|
|
1315
1270
|
import { existsSync as existsSync5, readFileSync as readFileSync8, statSync as statSync3 } from "node:fs";
|
|
1316
1271
|
import path2 from "node:path";
|
|
1317
1272
|
function stripSurroundingQuotes(value) {
|
|
@@ -1355,7 +1310,7 @@ function toEnvArray(env) {
|
|
|
1355
1310
|
return Object.entries(env).map(([key, value]) => `${key}=${value}`);
|
|
1356
1311
|
}
|
|
1357
1312
|
|
|
1358
|
-
// src/commands/deploy/
|
|
1313
|
+
// src/commands/deploy/internal/backend-deploy/dockerode-client/ports.ts
|
|
1359
1314
|
function parsePorts(ports) {
|
|
1360
1315
|
if (!ports || ports.length === 0) {
|
|
1361
1316
|
return {};
|
|
@@ -1385,7 +1340,7 @@ function parsePorts(ports) {
|
|
|
1385
1340
|
};
|
|
1386
1341
|
}
|
|
1387
1342
|
|
|
1388
|
-
// src/commands/deploy/
|
|
1343
|
+
// src/commands/deploy/internal/backend-deploy/image-tag.ts
|
|
1389
1344
|
var DEPLOY_IMAGE_TAG = /^(?!\.|-)[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/;
|
|
1390
1345
|
function assertDeployImageTag(tag) {
|
|
1391
1346
|
const t = tag.trim();
|
|
@@ -1396,13 +1351,13 @@ function assertDeployImageTag(tag) {
|
|
|
1396
1351
|
}
|
|
1397
1352
|
}
|
|
1398
1353
|
|
|
1399
|
-
// src/commands/deploy/
|
|
1354
|
+
// src/commands/deploy/internal/backend-deploy/local-docker-build.ts
|
|
1400
1355
|
import { platform } from "node:os";
|
|
1401
1356
|
|
|
1402
|
-
// src/commands/deploy/
|
|
1357
|
+
// src/commands/deploy/internal/backend-deploy/command-runner.ts
|
|
1403
1358
|
import { execSync } from "child_process";
|
|
1404
1359
|
|
|
1405
|
-
// src/commands/deploy/
|
|
1360
|
+
// src/commands/deploy/internal/backend-deploy/logger.ts
|
|
1406
1361
|
var Logger = class {
|
|
1407
1362
|
static info(message) {
|
|
1408
1363
|
console.log(`\x1B[36m[INFO]\x1B[0m ${message}`);
|
|
@@ -1418,7 +1373,7 @@ var Logger = class {
|
|
|
1418
1373
|
}
|
|
1419
1374
|
};
|
|
1420
1375
|
|
|
1421
|
-
// src/commands/deploy/
|
|
1376
|
+
// src/commands/deploy/internal/backend-deploy/command-runner.ts
|
|
1422
1377
|
var CommandRunner = class {
|
|
1423
1378
|
/**
|
|
1424
1379
|
* 执行命令
|
|
@@ -1455,7 +1410,7 @@ var CommandRunner = class {
|
|
|
1455
1410
|
}
|
|
1456
1411
|
};
|
|
1457
1412
|
|
|
1458
|
-
// src/commands/deploy/
|
|
1413
|
+
// src/commands/deploy/internal/backend-deploy/local-docker-build.ts
|
|
1459
1414
|
function dockerBuildPlatformFlags() {
|
|
1460
1415
|
return platform() === "darwin" ? ["--platform", "linux/amd64"] : [];
|
|
1461
1416
|
}
|
|
@@ -1468,7 +1423,7 @@ function buildDockerImageLocally(params, cwd) {
|
|
|
1468
1423
|
Logger.info("\u2713 \u955C\u50CF\u6784\u5EFA\u6210\u529F");
|
|
1469
1424
|
}
|
|
1470
1425
|
|
|
1471
|
-
// src/commands/deploy/
|
|
1426
|
+
// src/commands/deploy/internal/backend-deploy/registry-login-push.ts
|
|
1472
1427
|
function dockerLoginPrivateRegistry(params, cwd) {
|
|
1473
1428
|
const { registryUser, registryPassword, registryHost } = params;
|
|
1474
1429
|
Logger.info("\u68C0\u67E5\u914D\u7F6E\u53C2\u6570...");
|
|
@@ -1502,7 +1457,7 @@ function dockerPushImage(params, cwd) {
|
|
|
1502
1457
|
Logger.info("\u2713 \u955C\u50CF\u63A8\u9001\u6210\u529F");
|
|
1503
1458
|
}
|
|
1504
1459
|
|
|
1505
|
-
// src/commands/deploy/
|
|
1460
|
+
// src/commands/deploy/internal/backend-deploy/resolve-dockerfile.ts
|
|
1506
1461
|
import { existsSync as existsSync6 } from "node:fs";
|
|
1507
1462
|
import path3 from "node:path";
|
|
1508
1463
|
function resolveDockerBuildPaths(cwd) {
|
|
@@ -1515,7 +1470,7 @@ function resolveDockerBuildPaths(cwd) {
|
|
|
1515
1470
|
return dockerfilePath;
|
|
1516
1471
|
}
|
|
1517
1472
|
|
|
1518
|
-
// src/commands/deploy/
|
|
1473
|
+
// src/commands/deploy/internal/backend-deploy/backend-deploy-workflow.ts
|
|
1519
1474
|
var BackendDeployWorkflow = class {
|
|
1520
1475
|
constructor(params) {
|
|
1521
1476
|
this.params = params;
|
|
@@ -1636,7 +1591,7 @@ function registerDeployBackendCommands(program) {
|
|
|
1636
1591
|
import { copyFile, readdir as readdir2, stat } from "node:fs/promises";
|
|
1637
1592
|
import path7 from "node:path";
|
|
1638
1593
|
|
|
1639
|
-
// src/commands/deploy/
|
|
1594
|
+
// src/commands/deploy/internal/load-apm-dotenv.ts
|
|
1640
1595
|
import { existsSync as existsSync7, readFileSync as readFileSync9 } from "node:fs";
|
|
1641
1596
|
import { join as join8 } from "node:path";
|
|
1642
1597
|
function loadApmDotEnvIfPresent() {
|
|
@@ -1670,7 +1625,7 @@ function loadApmDotEnvIfPresent() {
|
|
|
1670
1625
|
}
|
|
1671
1626
|
}
|
|
1672
1627
|
|
|
1673
|
-
// src/commands/deploy/
|
|
1628
|
+
// src/commands/deploy/internal/minio.ts
|
|
1674
1629
|
import { statSync as statSync4 } from "node:fs";
|
|
1675
1630
|
import { readdir } from "node:fs/promises";
|
|
1676
1631
|
import path6 from "node:path";
|