ai-project-manage-cli 3.0.18 → 3.0.19
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 +30 -24
- 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",
|
|
@@ -593,8 +597,10 @@ function runConnect(opts) {
|
|
|
593
597
|
return;
|
|
594
598
|
}
|
|
595
599
|
const payload = msg.payload;
|
|
600
|
+
const apmRoot = join5(payload.cwd, ".apm");
|
|
601
|
+
console.log("[apm] ROOT:", apmRoot);
|
|
596
602
|
try {
|
|
597
|
-
await runPull(payload.requirementId,
|
|
603
|
+
await runPull(payload.requirementId, apmRoot);
|
|
598
604
|
} catch (pullErr) {
|
|
599
605
|
console.error("[apm] apm pull \u5931\u8D25:", pullErr);
|
|
600
606
|
throw pullErr;
|
|
@@ -673,7 +679,7 @@ function runConnect(opts) {
|
|
|
673
679
|
console.log("[Done]");
|
|
674
680
|
session.writeToFile(payload.cwd, payload.requirementId, run.agentId);
|
|
675
681
|
try {
|
|
676
|
-
await runUploadArtifact(payload.requirementId,
|
|
682
|
+
await runUploadArtifact(payload.requirementId, apmRoot);
|
|
677
683
|
} catch (pullErr) {
|
|
678
684
|
console.error("[apm] apm upload-artifact \u5931\u8D25:", pullErr);
|
|
679
685
|
throw pullErr;
|
|
@@ -693,13 +699,13 @@ function runConnect(opts) {
|
|
|
693
699
|
}
|
|
694
700
|
|
|
695
701
|
// src/commands/init.ts
|
|
696
|
-
import { join as
|
|
702
|
+
import { join as join6 } from "path";
|
|
697
703
|
import { readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "fs";
|
|
698
704
|
async function runInit(name) {
|
|
699
705
|
await ensureWorkspaceApmDirForInit();
|
|
700
706
|
await copyTemplateFiles(WORKSPACE_APM_DIR);
|
|
701
707
|
if (name) {
|
|
702
|
-
const apmConfigPath =
|
|
708
|
+
const apmConfigPath = join6(WORKSPACE_APM_DIR, "apm.config.json");
|
|
703
709
|
const config = readFileSync4(apmConfigPath, "utf8");
|
|
704
710
|
const configJson = JSON.parse(config);
|
|
705
711
|
configJson.name = name;
|
|
@@ -754,13 +760,13 @@ async function runLogin(opts) {
|
|
|
754
760
|
|
|
755
761
|
// src/commands/branch.ts
|
|
756
762
|
import { execFile } from "child_process";
|
|
757
|
-
import { resolve as
|
|
763
|
+
import { resolve as resolve4 } from "path";
|
|
758
764
|
import { promisify } from "util";
|
|
759
765
|
var execFileAsync = promisify(execFile);
|
|
760
766
|
async function fetchBaselineBranchFromApi(requirementId, cwd) {
|
|
761
767
|
const cfg = await ensureLoggedConfig();
|
|
762
768
|
const api = createApmApiClient(cfg);
|
|
763
|
-
const workdirPath =
|
|
769
|
+
const workdirPath = resolve4(cwd);
|
|
764
770
|
const { baselineBranch } = await api.cliRequirements.branchBaseline({
|
|
765
771
|
requirementId,
|
|
766
772
|
workdirPath
|
|
@@ -892,10 +898,10 @@ async function runBranch(requirementId, options = {}) {
|
|
|
892
898
|
|
|
893
899
|
// src/commands/refine.ts
|
|
894
900
|
import { readFileSync as readFileSync5 } from "fs";
|
|
895
|
-
import { join as
|
|
901
|
+
import { join as join7 } from "path";
|
|
896
902
|
async function runRefine(requirementId) {
|
|
897
903
|
const cfg = await ensureLoggedConfig();
|
|
898
|
-
const filePath =
|
|
904
|
+
const filePath = join7(WORKSPACE_APM_DIR, "workitems", requirementId, "prd.md");
|
|
899
905
|
const content = readFileSync5(filePath, "utf8");
|
|
900
906
|
const api = createApmApiClient(cfg);
|
|
901
907
|
const data = await api.cliRequirements.refine({ requirementId, content });
|
|
@@ -929,11 +935,11 @@ import path5 from "node:path";
|
|
|
929
935
|
|
|
930
936
|
// src/commands/deploy/lib/apm-config.ts
|
|
931
937
|
import { existsSync as existsSync3, readFileSync as readFileSync6 } from "node:fs";
|
|
932
|
-
import { resolve as
|
|
938
|
+
import { resolve as resolve5 } from "node:path";
|
|
933
939
|
function loadApmConfig(options) {
|
|
934
|
-
const p =
|
|
940
|
+
const p = resolve5(
|
|
935
941
|
process.cwd(),
|
|
936
|
-
options?.configPath ??
|
|
942
|
+
options?.configPath ?? resolve5(WORKSPACE_APM_DIR, "apm.config.json")
|
|
937
943
|
);
|
|
938
944
|
if (!existsSync3(p)) {
|
|
939
945
|
console.error(`\u672A\u627E\u5230\u914D\u7F6E\u6587\u4EF6\uFF1A${p}`);
|
|
@@ -1177,17 +1183,17 @@ var DockerodeClient = class {
|
|
|
1177
1183
|
await this.client.getImage(image).remove({ force: true });
|
|
1178
1184
|
}
|
|
1179
1185
|
async pullImage(image, auth) {
|
|
1180
|
-
const stream = await new Promise((
|
|
1186
|
+
const stream = await new Promise((resolve6, reject) => {
|
|
1181
1187
|
const pullOptions = auth ? { authconfig: auth } : void 0;
|
|
1182
1188
|
this.client.pull(image, pullOptions, (err, output) => {
|
|
1183
1189
|
if (err || !output) {
|
|
1184
1190
|
reject(err ?? new Error("docker pull \u8FD4\u56DE\u7A7A\u8F93\u51FA"));
|
|
1185
1191
|
return;
|
|
1186
1192
|
}
|
|
1187
|
-
|
|
1193
|
+
resolve6(output);
|
|
1188
1194
|
});
|
|
1189
1195
|
});
|
|
1190
|
-
await new Promise((
|
|
1196
|
+
await new Promise((resolve6, reject) => {
|
|
1191
1197
|
this.client.modem.followProgress(
|
|
1192
1198
|
stream,
|
|
1193
1199
|
(err) => {
|
|
@@ -1195,7 +1201,7 @@ var DockerodeClient = class {
|
|
|
1195
1201
|
reject(err);
|
|
1196
1202
|
return;
|
|
1197
1203
|
}
|
|
1198
|
-
|
|
1204
|
+
resolve6();
|
|
1199
1205
|
},
|
|
1200
1206
|
() => void 0
|
|
1201
1207
|
);
|
|
@@ -1578,9 +1584,9 @@ import path7 from "node:path";
|
|
|
1578
1584
|
|
|
1579
1585
|
// src/commands/deploy/lib/load-apm-dotenv.ts
|
|
1580
1586
|
import { existsSync as existsSync7, readFileSync as readFileSync9 } from "node:fs";
|
|
1581
|
-
import { join as
|
|
1587
|
+
import { join as join8 } from "node:path";
|
|
1582
1588
|
function loadApmDotEnvIfPresent() {
|
|
1583
|
-
const p =
|
|
1589
|
+
const p = join8(WORKSPACE_APM_DIR, ".env");
|
|
1584
1590
|
if (!existsSync7(p)) {
|
|
1585
1591
|
return;
|
|
1586
1592
|
}
|
|
@@ -1711,14 +1717,14 @@ var MinioClient = class {
|
|
|
1711
1717
|
async deleteObjectsByPrefix(bucket, prefix) {
|
|
1712
1718
|
const objectsStream = this.inner.listObjectsV2(bucket, prefix, true);
|
|
1713
1719
|
const keys = [];
|
|
1714
|
-
await new Promise((
|
|
1720
|
+
await new Promise((resolve6, reject) => {
|
|
1715
1721
|
objectsStream.on("data", (obj) => {
|
|
1716
1722
|
if (obj.name) {
|
|
1717
1723
|
keys.push(obj.name);
|
|
1718
1724
|
}
|
|
1719
1725
|
});
|
|
1720
1726
|
objectsStream.on("error", reject);
|
|
1721
|
-
objectsStream.on("end",
|
|
1727
|
+
objectsStream.on("end", resolve6);
|
|
1722
1728
|
});
|
|
1723
1729
|
const chunkSize = 500;
|
|
1724
1730
|
for (let i = 0; i < keys.length; i += chunkSize) {
|
|
@@ -1945,7 +1951,7 @@ function registerDeployCommands(program) {
|
|
|
1945
1951
|
function readCliVersion() {
|
|
1946
1952
|
try {
|
|
1947
1953
|
const dir = dirname2(fileURLToPath2(import.meta.url));
|
|
1948
|
-
const pkgPath =
|
|
1954
|
+
const pkgPath = join9(dir, "..", "package.json");
|
|
1949
1955
|
const pkg = JSON.parse(readFileSync10(pkgPath, "utf8"));
|
|
1950
1956
|
return pkg.version ?? "0.0.0";
|
|
1951
1957
|
} catch {
|