ai-project-manage-cli 3.0.20 → 3.0.22

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 +53 -30
  2. 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: {
@@ -237,6 +241,12 @@ import { appendFileSync } from "fs";
237
241
  import { resolve as resolve2 } from "path";
238
242
  var EventSession = class {
239
243
  events = [];
244
+ constructor(prompt) {
245
+ this.events.push({
246
+ type: "input",
247
+ content: prompt
248
+ });
249
+ }
240
250
  addEvent(event) {
241
251
  const latestEvent = this.events[this.events.length - 1];
242
252
  const formatedEvent = this.formatEvent(event);
@@ -326,17 +336,26 @@ var EventSession = class {
326
336
  this.events.forEach((event) => {
327
337
  const type = event.type;
328
338
  const content = (function(type2) {
329
- if (type2 === "assistant" || type2 === "thinking") {
330
- return `## ${type2}
339
+ if (type2 === "input") {
340
+ return `## \u7528\u6237\u8F93\u5165
341
+
342
+ ${event.content}
343
+ `;
344
+ }
345
+ if (type2 === "assistant") {
346
+ return `## \u6A21\u578B\u8F93\u51FA
347
+
348
+ ${event.content}
349
+ `;
350
+ }
351
+ if (type2 === "thinking") {
352
+ return `## \u6A21\u578B\u601D\u8003
331
353
 
332
354
  ${event.content}
333
355
  `;
334
356
  }
335
357
  if (type2 === "tool_call") {
336
- return `## \u5DE5\u5177\u8C03\u7528\uFF1A${event.name}(${event.call_id})
337
- ### \u53C2\u6570
338
- \`\`\`json
339
- ` + JSON.stringify(event.args, null, 2) + "\n```\n### \u7ED3\u679C\n```json\n" + JSON.stringify(event.result, null, 2) + "\n```\n";
358
+ return "````toolcall\n" + JSON.stringify(event, null, 2) + "\n````\n";
340
359
  }
341
360
  return `## \u672A\u77E5\u4E8B\u4EF6\uFF1A${type2}
342
361
 
@@ -622,17 +641,28 @@ function runConnect(opts) {
622
641
  console.error("[apm] apm pull \u5931\u8D25:", pullErr);
623
642
  throw pullErr;
624
643
  }
625
- const agent = await Agent.create({
626
- apiKey: payload.apiKey,
627
- model: { id: payload.model ?? "default" },
628
- local: { cwd: payload.cwd }
629
- });
644
+ const agent = await (async () => {
645
+ const options = {
646
+ apiKey: payload.apiKey,
647
+ model: { id: payload.model ?? "default" },
648
+ local: { cwd: payload.cwd }
649
+ };
650
+ if (payload.agentId) {
651
+ return Agent.resume(payload.agentId, options);
652
+ }
653
+ return Agent.create(options);
654
+ })();
630
655
  await api.cliRequirements.updateDevStatus({
631
656
  requirementId: payload.requirementId,
632
657
  status: "WORKING"
633
658
  });
659
+ await api.cliRequirements.updateTaskAgentId({
660
+ taskId: payload.taskId,
661
+ requirementId: payload.requirementId,
662
+ agentId: agent.agentId
663
+ });
634
664
  let IN_PROGRESS = false;
635
- const session = new EventSession();
665
+ const session = new EventSession(payload.prompt);
636
666
  const run = await agent.send(payload.prompt);
637
667
  for await (const event of run.stream()) {
638
668
  if (!IN_PROGRESS) {
@@ -656,24 +686,17 @@ function runConnect(opts) {
656
686
  if (event.type === "thinking") {
657
687
  const thinking = event.text;
658
688
  console.log(`[Thinking]`, thinking);
659
- session.addEvent(event);
660
689
  continue;
661
690
  }
662
691
  if (event.type === "tool_call") {
663
692
  if (event.status === "completed" || event.status === "error") {
664
693
  console.log(`[ToolCall(${event.call_id}) Result]`);
665
- console.log(JSON.stringify(event.args));
666
- console.log(JSON.stringify(event.result, null, 2));
667
- console.log("---------------\u8C03\u7528\u5B8C\u6210-----------------");
668
694
  }
669
695
  session.addEvent(event);
670
696
  continue;
671
697
  }
672
698
  if (event.type === "task") {
673
699
  console.log(`[Task:${event.status}]`);
674
- console.log("--------------------------------");
675
- console.log(event.text || "\u65E0");
676
- console.log("--------------------------------");
677
700
  session.addEvent(event);
678
701
  continue;
679
702
  }
@@ -777,13 +800,13 @@ async function runLogin(opts) {
777
800
 
778
801
  // src/commands/branch.ts
779
802
  import { execFile } from "child_process";
780
- import { resolve as resolve4 } from "path";
803
+ import { resolve as resolve3 } from "path";
781
804
  import { promisify } from "util";
782
805
  var execFileAsync = promisify(execFile);
783
806
  async function fetchBaselineBranchFromApi(requirementId, cwd) {
784
807
  const cfg = await ensureLoggedConfig();
785
808
  const api = createApmApiClient(cfg);
786
- const workdirPath = resolve4(cwd);
809
+ const workdirPath = resolve3(cwd);
787
810
  const { baselineBranch } = await api.cliRequirements.branchBaseline({
788
811
  requirementId,
789
812
  workdirPath
@@ -952,11 +975,11 @@ import path5 from "node:path";
952
975
 
953
976
  // src/commands/deploy/lib/apm-config.ts
954
977
  import { existsSync as existsSync3, readFileSync as readFileSync6 } from "node:fs";
955
- import { resolve as resolve5 } from "node:path";
978
+ import { resolve as resolve4 } from "node:path";
956
979
  function loadApmConfig(options) {
957
- const p = resolve5(
980
+ const p = resolve4(
958
981
  process.cwd(),
959
- options?.configPath ?? resolve5(WORKSPACE_APM_DIR, "apm.config.json")
982
+ options?.configPath ?? resolve4(WORKSPACE_APM_DIR, "apm.config.json")
960
983
  );
961
984
  if (!existsSync3(p)) {
962
985
  console.error(`\u672A\u627E\u5230\u914D\u7F6E\u6587\u4EF6\uFF1A${p}`);
@@ -1200,17 +1223,17 @@ var DockerodeClient = class {
1200
1223
  await this.client.getImage(image).remove({ force: true });
1201
1224
  }
1202
1225
  async pullImage(image, auth) {
1203
- const stream = await new Promise((resolve6, reject) => {
1226
+ const stream = await new Promise((resolve5, reject) => {
1204
1227
  const pullOptions = auth ? { authconfig: auth } : void 0;
1205
1228
  this.client.pull(image, pullOptions, (err, output) => {
1206
1229
  if (err || !output) {
1207
1230
  reject(err ?? new Error("docker pull \u8FD4\u56DE\u7A7A\u8F93\u51FA"));
1208
1231
  return;
1209
1232
  }
1210
- resolve6(output);
1233
+ resolve5(output);
1211
1234
  });
1212
1235
  });
1213
- await new Promise((resolve6, reject) => {
1236
+ await new Promise((resolve5, reject) => {
1214
1237
  this.client.modem.followProgress(
1215
1238
  stream,
1216
1239
  (err) => {
@@ -1218,7 +1241,7 @@ var DockerodeClient = class {
1218
1241
  reject(err);
1219
1242
  return;
1220
1243
  }
1221
- resolve6();
1244
+ resolve5();
1222
1245
  },
1223
1246
  () => void 0
1224
1247
  );
@@ -1734,14 +1757,14 @@ var MinioClient = class {
1734
1757
  async deleteObjectsByPrefix(bucket, prefix) {
1735
1758
  const objectsStream = this.inner.listObjectsV2(bucket, prefix, true);
1736
1759
  const keys = [];
1737
- await new Promise((resolve6, reject) => {
1760
+ await new Promise((resolve5, reject) => {
1738
1761
  objectsStream.on("data", (obj) => {
1739
1762
  if (obj.name) {
1740
1763
  keys.push(obj.name);
1741
1764
  }
1742
1765
  });
1743
1766
  objectsStream.on("error", reject);
1744
- objectsStream.on("end", resolve6);
1767
+ objectsStream.on("end", resolve5);
1745
1768
  });
1746
1769
  const chunkSize = 500;
1747
1770
  for (let i = 0; i < keys.length; i += chunkSize) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-project-manage-cli",
3
- "version": "3.0.20",
3
+ "version": "3.0.22",
4
4
  "description": "命令行工具:后续用于调用平台后端 API 完成运维与自动化操作",
5
5
  "type": "module",
6
6
  "private": false,