ai-project-manage-cli 3.0.18 → 3.0.20
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 +52 -29
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { readFileSync as readFileSync10 } from "fs";
|
|
5
|
-
import { dirname as dirname2, join as
|
|
5
|
+
import { dirname as dirname2, join as join9 } from "path";
|
|
6
6
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
7
7
|
import { Command } from "commander";
|
|
8
8
|
|
|
@@ -230,6 +230,7 @@ async function runComment(requirementId, file, model) {
|
|
|
230
230
|
import { randomUUID } from "crypto";
|
|
231
231
|
import WebSocket from "ws";
|
|
232
232
|
import { Agent } from "@cursor/sdk";
|
|
233
|
+
import { join as join5 } from "path";
|
|
233
234
|
|
|
234
235
|
// src/session-utils.ts
|
|
235
236
|
import { appendFileSync } from "fs";
|
|
@@ -277,17 +278,20 @@ var EventSession = class {
|
|
|
277
278
|
}
|
|
278
279
|
return;
|
|
279
280
|
}
|
|
280
|
-
this.events.push(
|
|
281
|
+
this.events.push(formatedEvent);
|
|
281
282
|
}
|
|
282
283
|
formatEvent(event) {
|
|
283
284
|
switch (event.type) {
|
|
284
285
|
case "assistant":
|
|
285
286
|
return {
|
|
286
287
|
type: "assistant",
|
|
287
|
-
content: event.message.content[0].text || ""
|
|
288
|
+
content: event.message.content[0].text || event.content || ""
|
|
288
289
|
};
|
|
289
290
|
case "thinking":
|
|
290
|
-
return {
|
|
291
|
+
return {
|
|
292
|
+
type: "thinking",
|
|
293
|
+
content: event.text || event.content || ""
|
|
294
|
+
};
|
|
291
295
|
case "tool_call":
|
|
292
296
|
return {
|
|
293
297
|
type: "tool_call",
|
|
@@ -320,10 +324,27 @@ var EventSession = class {
|
|
|
320
324
|
ensureDirExists(sessionsDir);
|
|
321
325
|
const sessionFile = resolve2(sessionsDir, `${agentId}.md`);
|
|
322
326
|
this.events.forEach((event) => {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
+
const type = event.type;
|
|
328
|
+
const content = (function(type2) {
|
|
329
|
+
if (type2 === "assistant" || type2 === "thinking") {
|
|
330
|
+
return `## ${type2}
|
|
331
|
+
|
|
332
|
+
${event.content}
|
|
333
|
+
`;
|
|
334
|
+
}
|
|
335
|
+
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";
|
|
340
|
+
}
|
|
341
|
+
return `## \u672A\u77E5\u4E8B\u4EF6\uFF1A${type2}
|
|
342
|
+
|
|
343
|
+
\`\`\`json
|
|
344
|
+
${JSON.stringify(event, null, 2)}
|
|
345
|
+
\`\`\``;
|
|
346
|
+
})(type);
|
|
347
|
+
appendFileSync(sessionFile, content + "\n");
|
|
327
348
|
});
|
|
328
349
|
}
|
|
329
350
|
};
|
|
@@ -366,7 +387,7 @@ function* walkMarkdownFiles(dir) {
|
|
|
366
387
|
}
|
|
367
388
|
}
|
|
368
389
|
async function deleteAllArtifactsForRequirement(api, requirementId) {
|
|
369
|
-
const pageSize =
|
|
390
|
+
const pageSize = 500;
|
|
370
391
|
let page = 1;
|
|
371
392
|
const rows = [];
|
|
372
393
|
while (true) {
|
|
@@ -593,8 +614,10 @@ function runConnect(opts) {
|
|
|
593
614
|
return;
|
|
594
615
|
}
|
|
595
616
|
const payload = msg.payload;
|
|
617
|
+
const apmRoot = join5(payload.cwd, ".apm");
|
|
618
|
+
console.log("[apm] ROOT:", apmRoot);
|
|
596
619
|
try {
|
|
597
|
-
await runPull(payload.requirementId,
|
|
620
|
+
await runPull(payload.requirementId, apmRoot);
|
|
598
621
|
} catch (pullErr) {
|
|
599
622
|
console.error("[apm] apm pull \u5931\u8D25:", pullErr);
|
|
600
623
|
throw pullErr;
|
|
@@ -673,7 +696,7 @@ function runConnect(opts) {
|
|
|
673
696
|
console.log("[Done]");
|
|
674
697
|
session.writeToFile(payload.cwd, payload.requirementId, run.agentId);
|
|
675
698
|
try {
|
|
676
|
-
await runUploadArtifact(payload.requirementId,
|
|
699
|
+
await runUploadArtifact(payload.requirementId, apmRoot);
|
|
677
700
|
} catch (pullErr) {
|
|
678
701
|
console.error("[apm] apm upload-artifact \u5931\u8D25:", pullErr);
|
|
679
702
|
throw pullErr;
|
|
@@ -693,13 +716,13 @@ function runConnect(opts) {
|
|
|
693
716
|
}
|
|
694
717
|
|
|
695
718
|
// src/commands/init.ts
|
|
696
|
-
import { join as
|
|
719
|
+
import { join as join6 } from "path";
|
|
697
720
|
import { readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "fs";
|
|
698
721
|
async function runInit(name) {
|
|
699
722
|
await ensureWorkspaceApmDirForInit();
|
|
700
723
|
await copyTemplateFiles(WORKSPACE_APM_DIR);
|
|
701
724
|
if (name) {
|
|
702
|
-
const apmConfigPath =
|
|
725
|
+
const apmConfigPath = join6(WORKSPACE_APM_DIR, "apm.config.json");
|
|
703
726
|
const config = readFileSync4(apmConfigPath, "utf8");
|
|
704
727
|
const configJson = JSON.parse(config);
|
|
705
728
|
configJson.name = name;
|
|
@@ -754,13 +777,13 @@ async function runLogin(opts) {
|
|
|
754
777
|
|
|
755
778
|
// src/commands/branch.ts
|
|
756
779
|
import { execFile } from "child_process";
|
|
757
|
-
import { resolve as
|
|
780
|
+
import { resolve as resolve4 } from "path";
|
|
758
781
|
import { promisify } from "util";
|
|
759
782
|
var execFileAsync = promisify(execFile);
|
|
760
783
|
async function fetchBaselineBranchFromApi(requirementId, cwd) {
|
|
761
784
|
const cfg = await ensureLoggedConfig();
|
|
762
785
|
const api = createApmApiClient(cfg);
|
|
763
|
-
const workdirPath =
|
|
786
|
+
const workdirPath = resolve4(cwd);
|
|
764
787
|
const { baselineBranch } = await api.cliRequirements.branchBaseline({
|
|
765
788
|
requirementId,
|
|
766
789
|
workdirPath
|
|
@@ -892,10 +915,10 @@ async function runBranch(requirementId, options = {}) {
|
|
|
892
915
|
|
|
893
916
|
// src/commands/refine.ts
|
|
894
917
|
import { readFileSync as readFileSync5 } from "fs";
|
|
895
|
-
import { join as
|
|
918
|
+
import { join as join7 } from "path";
|
|
896
919
|
async function runRefine(requirementId) {
|
|
897
920
|
const cfg = await ensureLoggedConfig();
|
|
898
|
-
const filePath =
|
|
921
|
+
const filePath = join7(WORKSPACE_APM_DIR, "workitems", requirementId, "prd.md");
|
|
899
922
|
const content = readFileSync5(filePath, "utf8");
|
|
900
923
|
const api = createApmApiClient(cfg);
|
|
901
924
|
const data = await api.cliRequirements.refine({ requirementId, content });
|
|
@@ -929,11 +952,11 @@ import path5 from "node:path";
|
|
|
929
952
|
|
|
930
953
|
// src/commands/deploy/lib/apm-config.ts
|
|
931
954
|
import { existsSync as existsSync3, readFileSync as readFileSync6 } from "node:fs";
|
|
932
|
-
import { resolve as
|
|
955
|
+
import { resolve as resolve5 } from "node:path";
|
|
933
956
|
function loadApmConfig(options) {
|
|
934
|
-
const p =
|
|
957
|
+
const p = resolve5(
|
|
935
958
|
process.cwd(),
|
|
936
|
-
options?.configPath ??
|
|
959
|
+
options?.configPath ?? resolve5(WORKSPACE_APM_DIR, "apm.config.json")
|
|
937
960
|
);
|
|
938
961
|
if (!existsSync3(p)) {
|
|
939
962
|
console.error(`\u672A\u627E\u5230\u914D\u7F6E\u6587\u4EF6\uFF1A${p}`);
|
|
@@ -1177,17 +1200,17 @@ var DockerodeClient = class {
|
|
|
1177
1200
|
await this.client.getImage(image).remove({ force: true });
|
|
1178
1201
|
}
|
|
1179
1202
|
async pullImage(image, auth) {
|
|
1180
|
-
const stream = await new Promise((
|
|
1203
|
+
const stream = await new Promise((resolve6, reject) => {
|
|
1181
1204
|
const pullOptions = auth ? { authconfig: auth } : void 0;
|
|
1182
1205
|
this.client.pull(image, pullOptions, (err, output) => {
|
|
1183
1206
|
if (err || !output) {
|
|
1184
1207
|
reject(err ?? new Error("docker pull \u8FD4\u56DE\u7A7A\u8F93\u51FA"));
|
|
1185
1208
|
return;
|
|
1186
1209
|
}
|
|
1187
|
-
|
|
1210
|
+
resolve6(output);
|
|
1188
1211
|
});
|
|
1189
1212
|
});
|
|
1190
|
-
await new Promise((
|
|
1213
|
+
await new Promise((resolve6, reject) => {
|
|
1191
1214
|
this.client.modem.followProgress(
|
|
1192
1215
|
stream,
|
|
1193
1216
|
(err) => {
|
|
@@ -1195,7 +1218,7 @@ var DockerodeClient = class {
|
|
|
1195
1218
|
reject(err);
|
|
1196
1219
|
return;
|
|
1197
1220
|
}
|
|
1198
|
-
|
|
1221
|
+
resolve6();
|
|
1199
1222
|
},
|
|
1200
1223
|
() => void 0
|
|
1201
1224
|
);
|
|
@@ -1578,9 +1601,9 @@ import path7 from "node:path";
|
|
|
1578
1601
|
|
|
1579
1602
|
// src/commands/deploy/lib/load-apm-dotenv.ts
|
|
1580
1603
|
import { existsSync as existsSync7, readFileSync as readFileSync9 } from "node:fs";
|
|
1581
|
-
import { join as
|
|
1604
|
+
import { join as join8 } from "node:path";
|
|
1582
1605
|
function loadApmDotEnvIfPresent() {
|
|
1583
|
-
const p =
|
|
1606
|
+
const p = join8(WORKSPACE_APM_DIR, ".env");
|
|
1584
1607
|
if (!existsSync7(p)) {
|
|
1585
1608
|
return;
|
|
1586
1609
|
}
|
|
@@ -1711,14 +1734,14 @@ var MinioClient = class {
|
|
|
1711
1734
|
async deleteObjectsByPrefix(bucket, prefix) {
|
|
1712
1735
|
const objectsStream = this.inner.listObjectsV2(bucket, prefix, true);
|
|
1713
1736
|
const keys = [];
|
|
1714
|
-
await new Promise((
|
|
1737
|
+
await new Promise((resolve6, reject) => {
|
|
1715
1738
|
objectsStream.on("data", (obj) => {
|
|
1716
1739
|
if (obj.name) {
|
|
1717
1740
|
keys.push(obj.name);
|
|
1718
1741
|
}
|
|
1719
1742
|
});
|
|
1720
1743
|
objectsStream.on("error", reject);
|
|
1721
|
-
objectsStream.on("end",
|
|
1744
|
+
objectsStream.on("end", resolve6);
|
|
1722
1745
|
});
|
|
1723
1746
|
const chunkSize = 500;
|
|
1724
1747
|
for (let i = 0; i < keys.length; i += chunkSize) {
|
|
@@ -1945,7 +1968,7 @@ function registerDeployCommands(program) {
|
|
|
1945
1968
|
function readCliVersion() {
|
|
1946
1969
|
try {
|
|
1947
1970
|
const dir = dirname2(fileURLToPath2(import.meta.url));
|
|
1948
|
-
const pkgPath =
|
|
1971
|
+
const pkgPath = join9(dir, "..", "package.json");
|
|
1949
1972
|
const pkg = JSON.parse(readFileSync10(pkgPath, "utf8"));
|
|
1950
1973
|
return pkg.version ?? "0.0.0";
|
|
1951
1974
|
} catch {
|