ai-project-manage-cli 3.0.19 → 3.0.21
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 +53 -28
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -118,6 +118,10 @@ var requestConfig = {
|
|
|
118
118
|
updateTaskStatus: defineEndpoint({
|
|
119
119
|
method: "POST",
|
|
120
120
|
path: "/cli/requirements/update-task-status"
|
|
121
|
+
}),
|
|
122
|
+
updateTaskAgentId: defineEndpoint({
|
|
123
|
+
method: "POST",
|
|
124
|
+
path: "/cli/requirements/update-task-agent-id"
|
|
121
125
|
})
|
|
122
126
|
},
|
|
123
127
|
requirementArtifact: {
|
|
@@ -324,10 +328,27 @@ var EventSession = class {
|
|
|
324
328
|
ensureDirExists(sessionsDir);
|
|
325
329
|
const sessionFile = resolve2(sessionsDir, `${agentId}.md`);
|
|
326
330
|
this.events.forEach((event) => {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
+
const type = event.type;
|
|
332
|
+
const content = (function(type2) {
|
|
333
|
+
if (type2 === "assistant" || type2 === "thinking") {
|
|
334
|
+
return `## ${type2}
|
|
335
|
+
|
|
336
|
+
${event.content}
|
|
337
|
+
`;
|
|
338
|
+
}
|
|
339
|
+
if (type2 === "tool_call") {
|
|
340
|
+
return `## \u5DE5\u5177\u8C03\u7528\uFF1A${event.name}(${event.call_id})
|
|
341
|
+
### \u53C2\u6570
|
|
342
|
+
\`\`\`json
|
|
343
|
+
` + JSON.stringify(event.args, null, 2) + "\n```\n### \u7ED3\u679C\n```json\n" + JSON.stringify(event.result, null, 2) + "\n```\n";
|
|
344
|
+
}
|
|
345
|
+
return `## \u672A\u77E5\u4E8B\u4EF6\uFF1A${type2}
|
|
346
|
+
|
|
347
|
+
\`\`\`json
|
|
348
|
+
${JSON.stringify(event, null, 2)}
|
|
349
|
+
\`\`\``;
|
|
350
|
+
})(type);
|
|
351
|
+
appendFileSync(sessionFile, content + "\n");
|
|
331
352
|
});
|
|
332
353
|
}
|
|
333
354
|
};
|
|
@@ -370,7 +391,7 @@ function* walkMarkdownFiles(dir) {
|
|
|
370
391
|
}
|
|
371
392
|
}
|
|
372
393
|
async function deleteAllArtifactsForRequirement(api, requirementId) {
|
|
373
|
-
const pageSize =
|
|
394
|
+
const pageSize = 500;
|
|
374
395
|
let page = 1;
|
|
375
396
|
const rows = [];
|
|
376
397
|
while (true) {
|
|
@@ -605,15 +626,26 @@ function runConnect(opts) {
|
|
|
605
626
|
console.error("[apm] apm pull \u5931\u8D25:", pullErr);
|
|
606
627
|
throw pullErr;
|
|
607
628
|
}
|
|
608
|
-
const agent = await
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
629
|
+
const agent = await (async () => {
|
|
630
|
+
const options = {
|
|
631
|
+
apiKey: payload.apiKey,
|
|
632
|
+
model: { id: payload.model ?? "default" },
|
|
633
|
+
local: { cwd: payload.cwd }
|
|
634
|
+
};
|
|
635
|
+
if (payload.agentId) {
|
|
636
|
+
return Agent.resume(payload.agentId, options);
|
|
637
|
+
}
|
|
638
|
+
return Agent.create(options);
|
|
639
|
+
})();
|
|
613
640
|
await api.cliRequirements.updateDevStatus({
|
|
614
641
|
requirementId: payload.requirementId,
|
|
615
642
|
status: "WORKING"
|
|
616
643
|
});
|
|
644
|
+
await api.cliRequirements.updateTaskAgentId({
|
|
645
|
+
taskId: payload.taskId,
|
|
646
|
+
requirementId: payload.requirementId,
|
|
647
|
+
agentId: agent.agentId
|
|
648
|
+
});
|
|
617
649
|
let IN_PROGRESS = false;
|
|
618
650
|
const session = new EventSession();
|
|
619
651
|
const run = await agent.send(payload.prompt);
|
|
@@ -639,24 +671,17 @@ function runConnect(opts) {
|
|
|
639
671
|
if (event.type === "thinking") {
|
|
640
672
|
const thinking = event.text;
|
|
641
673
|
console.log(`[Thinking]`, thinking);
|
|
642
|
-
session.addEvent(event);
|
|
643
674
|
continue;
|
|
644
675
|
}
|
|
645
676
|
if (event.type === "tool_call") {
|
|
646
677
|
if (event.status === "completed" || event.status === "error") {
|
|
647
678
|
console.log(`[ToolCall(${event.call_id}) Result]`);
|
|
648
|
-
console.log(JSON.stringify(event.args));
|
|
649
|
-
console.log(JSON.stringify(event.result, null, 2));
|
|
650
|
-
console.log("---------------\u8C03\u7528\u5B8C\u6210-----------------");
|
|
651
679
|
}
|
|
652
680
|
session.addEvent(event);
|
|
653
681
|
continue;
|
|
654
682
|
}
|
|
655
683
|
if (event.type === "task") {
|
|
656
684
|
console.log(`[Task:${event.status}]`);
|
|
657
|
-
console.log("--------------------------------");
|
|
658
|
-
console.log(event.text || "\u65E0");
|
|
659
|
-
console.log("--------------------------------");
|
|
660
685
|
session.addEvent(event);
|
|
661
686
|
continue;
|
|
662
687
|
}
|
|
@@ -760,13 +785,13 @@ async function runLogin(opts) {
|
|
|
760
785
|
|
|
761
786
|
// src/commands/branch.ts
|
|
762
787
|
import { execFile } from "child_process";
|
|
763
|
-
import { resolve as
|
|
788
|
+
import { resolve as resolve3 } from "path";
|
|
764
789
|
import { promisify } from "util";
|
|
765
790
|
var execFileAsync = promisify(execFile);
|
|
766
791
|
async function fetchBaselineBranchFromApi(requirementId, cwd) {
|
|
767
792
|
const cfg = await ensureLoggedConfig();
|
|
768
793
|
const api = createApmApiClient(cfg);
|
|
769
|
-
const workdirPath =
|
|
794
|
+
const workdirPath = resolve3(cwd);
|
|
770
795
|
const { baselineBranch } = await api.cliRequirements.branchBaseline({
|
|
771
796
|
requirementId,
|
|
772
797
|
workdirPath
|
|
@@ -935,11 +960,11 @@ import path5 from "node:path";
|
|
|
935
960
|
|
|
936
961
|
// src/commands/deploy/lib/apm-config.ts
|
|
937
962
|
import { existsSync as existsSync3, readFileSync as readFileSync6 } from "node:fs";
|
|
938
|
-
import { resolve as
|
|
963
|
+
import { resolve as resolve4 } from "node:path";
|
|
939
964
|
function loadApmConfig(options) {
|
|
940
|
-
const p =
|
|
965
|
+
const p = resolve4(
|
|
941
966
|
process.cwd(),
|
|
942
|
-
options?.configPath ??
|
|
967
|
+
options?.configPath ?? resolve4(WORKSPACE_APM_DIR, "apm.config.json")
|
|
943
968
|
);
|
|
944
969
|
if (!existsSync3(p)) {
|
|
945
970
|
console.error(`\u672A\u627E\u5230\u914D\u7F6E\u6587\u4EF6\uFF1A${p}`);
|
|
@@ -1183,17 +1208,17 @@ var DockerodeClient = class {
|
|
|
1183
1208
|
await this.client.getImage(image).remove({ force: true });
|
|
1184
1209
|
}
|
|
1185
1210
|
async pullImage(image, auth) {
|
|
1186
|
-
const stream = await new Promise((
|
|
1211
|
+
const stream = await new Promise((resolve5, reject) => {
|
|
1187
1212
|
const pullOptions = auth ? { authconfig: auth } : void 0;
|
|
1188
1213
|
this.client.pull(image, pullOptions, (err, output) => {
|
|
1189
1214
|
if (err || !output) {
|
|
1190
1215
|
reject(err ?? new Error("docker pull \u8FD4\u56DE\u7A7A\u8F93\u51FA"));
|
|
1191
1216
|
return;
|
|
1192
1217
|
}
|
|
1193
|
-
|
|
1218
|
+
resolve5(output);
|
|
1194
1219
|
});
|
|
1195
1220
|
});
|
|
1196
|
-
await new Promise((
|
|
1221
|
+
await new Promise((resolve5, reject) => {
|
|
1197
1222
|
this.client.modem.followProgress(
|
|
1198
1223
|
stream,
|
|
1199
1224
|
(err) => {
|
|
@@ -1201,7 +1226,7 @@ var DockerodeClient = class {
|
|
|
1201
1226
|
reject(err);
|
|
1202
1227
|
return;
|
|
1203
1228
|
}
|
|
1204
|
-
|
|
1229
|
+
resolve5();
|
|
1205
1230
|
},
|
|
1206
1231
|
() => void 0
|
|
1207
1232
|
);
|
|
@@ -1717,14 +1742,14 @@ var MinioClient = class {
|
|
|
1717
1742
|
async deleteObjectsByPrefix(bucket, prefix) {
|
|
1718
1743
|
const objectsStream = this.inner.listObjectsV2(bucket, prefix, true);
|
|
1719
1744
|
const keys = [];
|
|
1720
|
-
await new Promise((
|
|
1745
|
+
await new Promise((resolve5, reject) => {
|
|
1721
1746
|
objectsStream.on("data", (obj) => {
|
|
1722
1747
|
if (obj.name) {
|
|
1723
1748
|
keys.push(obj.name);
|
|
1724
1749
|
}
|
|
1725
1750
|
});
|
|
1726
1751
|
objectsStream.on("error", reject);
|
|
1727
|
-
objectsStream.on("end",
|
|
1752
|
+
objectsStream.on("end", resolve5);
|
|
1728
1753
|
});
|
|
1729
1754
|
const chunkSize = 500;
|
|
1730
1755
|
for (let i = 0; i < keys.length; i += chunkSize) {
|