ai-project-manage-cli 7.1.3 → 7.1.5
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 +48 -16
- package/dist/webide-message-worker.js +55 -23
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -6342,16 +6342,16 @@ var EventSession = class {
|
|
|
6342
6342
|
return;
|
|
6343
6343
|
}
|
|
6344
6344
|
if (formatedEvent.type === "tool_call") {
|
|
6345
|
-
const
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6345
|
+
const callId = typeof formatedEvent.call_id === "string" ? formatedEvent.call_id.trim() : "";
|
|
6346
|
+
if (callId) {
|
|
6347
|
+
const existingIndex = this.events.findIndex(
|
|
6348
|
+
(e) => e.type === "tool_call" && typeof e.call_id === "string" && e.call_id === callId
|
|
6349
|
+
);
|
|
6350
|
+
if (existingIndex >= 0) {
|
|
6351
|
+
mergeToolCallEvent(this.events[existingIndex], formatedEvent);
|
|
6352
|
+
this.markDirty(existingIndex);
|
|
6353
|
+
return;
|
|
6354
|
+
}
|
|
6355
6355
|
}
|
|
6356
6356
|
this.events.push(formatedEvent);
|
|
6357
6357
|
this.markDirty(this.events.length - 1);
|
|
@@ -6413,15 +6413,18 @@ var EventSession = class {
|
|
|
6413
6413
|
type: "thinking",
|
|
6414
6414
|
content: event.text || event.content || ""
|
|
6415
6415
|
};
|
|
6416
|
-
case "tool_call":
|
|
6416
|
+
case "tool_call": {
|
|
6417
|
+
const raw = event;
|
|
6418
|
+
const callId = String(raw.call_id ?? raw.callId ?? "").trim();
|
|
6417
6419
|
return {
|
|
6418
6420
|
type: "tool_call",
|
|
6419
6421
|
args: event.args,
|
|
6420
6422
|
result: event.result,
|
|
6421
6423
|
status: event.status,
|
|
6422
|
-
call_id:
|
|
6424
|
+
call_id: callId,
|
|
6423
6425
|
name: event.name
|
|
6424
6426
|
};
|
|
6427
|
+
}
|
|
6425
6428
|
case "task":
|
|
6426
6429
|
return {
|
|
6427
6430
|
type: "task",
|
|
@@ -6486,6 +6489,24 @@ var EventSession = class {
|
|
|
6486
6489
|
return this.events.map((event) => formatLogEvent(event.type, event)).join("\n");
|
|
6487
6490
|
}
|
|
6488
6491
|
};
|
|
6492
|
+
function mergeToolCallEvent(existing, incoming) {
|
|
6493
|
+
if (incoming.name) {
|
|
6494
|
+
existing.name = incoming.name;
|
|
6495
|
+
}
|
|
6496
|
+
if (incoming.status) {
|
|
6497
|
+
existing.status = incoming.status;
|
|
6498
|
+
}
|
|
6499
|
+
if (incoming.args != null && typeof incoming.args === "object" && !Array.isArray(incoming.args) && Object.keys(incoming.args).length > 0) {
|
|
6500
|
+
existing.args = { ...existing.args ?? {}, ...incoming.args };
|
|
6501
|
+
}
|
|
6502
|
+
if (incoming.result != null) {
|
|
6503
|
+
if (typeof incoming.result === "object" && !Array.isArray(incoming.result) && typeof existing.result === "object" && existing.result != null && !Array.isArray(existing.result)) {
|
|
6504
|
+
existing.result = { ...existing.result, ...incoming.result };
|
|
6505
|
+
} else {
|
|
6506
|
+
existing.result = incoming.result;
|
|
6507
|
+
}
|
|
6508
|
+
}
|
|
6509
|
+
}
|
|
6489
6510
|
function formatLogEvent(type, event) {
|
|
6490
6511
|
if (type === "input") {
|
|
6491
6512
|
return `## \u7528\u6237\u8F93\u5165
|
|
@@ -6852,6 +6873,16 @@ function withPlanModeToolHint(prompt, mode) {
|
|
|
6852
6873
|
${PLAN_MODE_ASK_QUESTION_HINT}`;
|
|
6853
6874
|
}
|
|
6854
6875
|
|
|
6876
|
+
// src/commands/connect/local-agent-store.ts
|
|
6877
|
+
import { mkdirSync as mkdirSync10 } from "node:fs";
|
|
6878
|
+
import { join as join18 } from "node:path";
|
|
6879
|
+
import { JsonlLocalAgentStore } from "@cursor/sdk";
|
|
6880
|
+
function createWorkspaceLocalAgentStore(workdir) {
|
|
6881
|
+
const rootDir = join18(workdir, ".apm", "cursor-agent-store");
|
|
6882
|
+
mkdirSync10(rootDir, { recursive: true });
|
|
6883
|
+
return new JsonlLocalAgentStore(rootDir);
|
|
6884
|
+
}
|
|
6885
|
+
|
|
6855
6886
|
// src/commands/connect/cursor-agent.ts
|
|
6856
6887
|
setMaxListeners2(100);
|
|
6857
6888
|
installAbortSignalDebug();
|
|
@@ -6885,6 +6916,7 @@ async function obtainAgent(ctx) {
|
|
|
6885
6916
|
model: { id: ctx.model || "default" },
|
|
6886
6917
|
local: {
|
|
6887
6918
|
cwd: ctx.cwd,
|
|
6919
|
+
store: createWorkspaceLocalAgentStore(ctx.workdir),
|
|
6888
6920
|
...ctx.customTools ? { customTools: ctx.customTools } : {}
|
|
6889
6921
|
},
|
|
6890
6922
|
...ctx.mode ? { mode: ctx.mode } : {}
|
|
@@ -7110,10 +7142,10 @@ async function ensureMessageHasReply(cfg, sessionId, messageId, fallback) {
|
|
|
7110
7142
|
|
|
7111
7143
|
// src/commands/connect/cli-version-sync.ts
|
|
7112
7144
|
import { existsSync as existsSync24, readFileSync as readFileSync17, writeFileSync as writeFileSync15 } from "fs";
|
|
7113
|
-
import { join as
|
|
7145
|
+
import { join as join19 } from "path";
|
|
7114
7146
|
var CLI_VERSION_FILE = ".cli-version.json";
|
|
7115
7147
|
function manifestPath(apmDir) {
|
|
7116
|
-
return
|
|
7148
|
+
return join19(apmDir, CLI_VERSION_FILE);
|
|
7117
7149
|
}
|
|
7118
7150
|
function loadManifest4(apmDir) {
|
|
7119
7151
|
const path19 = toFsPath(manifestPath(apmDir));
|
|
@@ -7218,8 +7250,8 @@ function createRunSlotPool(maxConcurrent = DEFAULT_MAX_CONCURRENT, options = {})
|
|
|
7218
7250
|
// src/commands/connect/webide-worker-pool.ts
|
|
7219
7251
|
import { Worker } from "node:worker_threads";
|
|
7220
7252
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
7221
|
-
import { dirname as dirname7, join as
|
|
7222
|
-
var workerFile =
|
|
7253
|
+
import { dirname as dirname7, join as join20 } from "node:path";
|
|
7254
|
+
var workerFile = join20(
|
|
7223
7255
|
dirname7(fileURLToPath3(import.meta.url)),
|
|
7224
7256
|
"webide-message-worker.js"
|
|
7225
7257
|
);
|
|
@@ -327,16 +327,16 @@ var EventSession = class {
|
|
|
327
327
|
return;
|
|
328
328
|
}
|
|
329
329
|
if (formatedEvent.type === "tool_call") {
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
330
|
+
const callId = typeof formatedEvent.call_id === "string" ? formatedEvent.call_id.trim() : "";
|
|
331
|
+
if (callId) {
|
|
332
|
+
const existingIndex = this.events.findIndex(
|
|
333
|
+
(e) => e.type === "tool_call" && typeof e.call_id === "string" && e.call_id === callId
|
|
334
|
+
);
|
|
335
|
+
if (existingIndex >= 0) {
|
|
336
|
+
mergeToolCallEvent(this.events[existingIndex], formatedEvent);
|
|
337
|
+
this.markDirty(existingIndex);
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
340
|
}
|
|
341
341
|
this.events.push(formatedEvent);
|
|
342
342
|
this.markDirty(this.events.length - 1);
|
|
@@ -398,15 +398,18 @@ var EventSession = class {
|
|
|
398
398
|
type: "thinking",
|
|
399
399
|
content: event.text || event.content || ""
|
|
400
400
|
};
|
|
401
|
-
case "tool_call":
|
|
401
|
+
case "tool_call": {
|
|
402
|
+
const raw = event;
|
|
403
|
+
const callId = String(raw.call_id ?? raw.callId ?? "").trim();
|
|
402
404
|
return {
|
|
403
405
|
type: "tool_call",
|
|
404
406
|
args: event.args,
|
|
405
407
|
result: event.result,
|
|
406
408
|
status: event.status,
|
|
407
|
-
call_id:
|
|
409
|
+
call_id: callId,
|
|
408
410
|
name: event.name
|
|
409
411
|
};
|
|
412
|
+
}
|
|
410
413
|
case "task":
|
|
411
414
|
return {
|
|
412
415
|
type: "task",
|
|
@@ -471,6 +474,24 @@ var EventSession = class {
|
|
|
471
474
|
return this.events.map((event) => formatLogEvent(event.type, event)).join("\n");
|
|
472
475
|
}
|
|
473
476
|
};
|
|
477
|
+
function mergeToolCallEvent(existing, incoming) {
|
|
478
|
+
if (incoming.name) {
|
|
479
|
+
existing.name = incoming.name;
|
|
480
|
+
}
|
|
481
|
+
if (incoming.status) {
|
|
482
|
+
existing.status = incoming.status;
|
|
483
|
+
}
|
|
484
|
+
if (incoming.args != null && typeof incoming.args === "object" && !Array.isArray(incoming.args) && Object.keys(incoming.args).length > 0) {
|
|
485
|
+
existing.args = { ...existing.args ?? {}, ...incoming.args };
|
|
486
|
+
}
|
|
487
|
+
if (incoming.result != null) {
|
|
488
|
+
if (typeof incoming.result === "object" && !Array.isArray(incoming.result) && typeof existing.result === "object" && existing.result != null && !Array.isArray(existing.result)) {
|
|
489
|
+
existing.result = { ...existing.result, ...incoming.result };
|
|
490
|
+
} else {
|
|
491
|
+
existing.result = incoming.result;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
474
495
|
function formatLogEvent(type, event) {
|
|
475
496
|
if (type === "input") {
|
|
476
497
|
return `## \u7528\u6237\u8F93\u5165
|
|
@@ -1095,6 +1116,16 @@ function withPlanModeToolHint(prompt, mode) {
|
|
|
1095
1116
|
${PLAN_MODE_ASK_QUESTION_HINT}`;
|
|
1096
1117
|
}
|
|
1097
1118
|
|
|
1119
|
+
// src/commands/connect/local-agent-store.ts
|
|
1120
|
+
import { mkdirSync as mkdirSync4 } from "node:fs";
|
|
1121
|
+
import { join as join3 } from "node:path";
|
|
1122
|
+
import { JsonlLocalAgentStore } from "@cursor/sdk";
|
|
1123
|
+
function createWorkspaceLocalAgentStore(workdir) {
|
|
1124
|
+
const rootDir = join3(workdir, ".apm", "cursor-agent-store");
|
|
1125
|
+
mkdirSync4(rootDir, { recursive: true });
|
|
1126
|
+
return new JsonlLocalAgentStore(rootDir);
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1098
1129
|
// src/commands/connect/cursor-agent.ts
|
|
1099
1130
|
setMaxListeners2(100);
|
|
1100
1131
|
installAbortSignalDebug();
|
|
@@ -1128,6 +1159,7 @@ async function obtainAgent(ctx) {
|
|
|
1128
1159
|
model: { id: ctx.model || "default" },
|
|
1129
1160
|
local: {
|
|
1130
1161
|
cwd: ctx.cwd,
|
|
1162
|
+
store: createWorkspaceLocalAgentStore(ctx.workdir),
|
|
1131
1163
|
...ctx.customTools ? { customTools: ctx.customTools } : {}
|
|
1132
1164
|
},
|
|
1133
1165
|
...ctx.mode ? { mode: ctx.mode } : {}
|
|
@@ -1316,7 +1348,7 @@ async function runCursorAgent(cfg, ctx, options) {
|
|
|
1316
1348
|
}
|
|
1317
1349
|
|
|
1318
1350
|
// src/commands/connect/webide-agent-registry.ts
|
|
1319
|
-
import { existsSync as existsSync3, mkdirSync as
|
|
1351
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync5, readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "node:fs";
|
|
1320
1352
|
import { dirname as dirname3, resolve as resolve4 } from "node:path";
|
|
1321
1353
|
function registryPath2(workdir, taskId) {
|
|
1322
1354
|
return resolve4(workdir, ".apm", "webide", taskId, "cursor-agent.json");
|
|
@@ -1338,7 +1370,7 @@ function readRegistry2(path) {
|
|
|
1338
1370
|
return {};
|
|
1339
1371
|
}
|
|
1340
1372
|
function writeRegistry2(path, registry) {
|
|
1341
|
-
|
|
1373
|
+
mkdirSync5(dirname3(path), { recursive: true });
|
|
1342
1374
|
writeFileSync4(path, `${JSON.stringify(registry, null, 2)}
|
|
1343
1375
|
`, "utf8");
|
|
1344
1376
|
}
|
|
@@ -1643,11 +1675,11 @@ function resolveMessageReplyFallback(fallback) {
|
|
|
1643
1675
|
}
|
|
1644
1676
|
|
|
1645
1677
|
// src/commands/init.ts
|
|
1646
|
-
import { join as
|
|
1678
|
+
import { join as join6 } from "path";
|
|
1647
1679
|
import { readFileSync as readFileSync6, writeFileSync as writeFileSync7 } from "fs";
|
|
1648
1680
|
|
|
1649
1681
|
// src/deployment-config-sync.ts
|
|
1650
|
-
import { join as
|
|
1682
|
+
import { join as join4 } from "path";
|
|
1651
1683
|
import { writeFileSync as writeFileSync5 } from "fs";
|
|
1652
1684
|
|
|
1653
1685
|
// src/git-remote.ts
|
|
@@ -1838,7 +1870,7 @@ ${diagnostic ?? ""}
|
|
|
1838
1870
|
return { synced: false, repositoryId };
|
|
1839
1871
|
}
|
|
1840
1872
|
const targetApmDir = apmDir ?? workspaceApmDir(workdirPath);
|
|
1841
|
-
const apmConfigPath = toFsPath(
|
|
1873
|
+
const apmConfigPath = toFsPath(join4(targetApmDir, "apm.config.json"));
|
|
1842
1874
|
writeFileSync5(apmConfigPath, `${JSON.stringify(parsed, null, 2)}
|
|
1843
1875
|
`, "utf8");
|
|
1844
1876
|
console.log(`[apm] \u5DF2\u540C\u6B65\u5E73\u53F0\u90E8\u7F72\u914D\u7F6E: ${config.name}`);
|
|
@@ -1854,14 +1886,14 @@ import {
|
|
|
1854
1886
|
rmSync,
|
|
1855
1887
|
writeFileSync as writeFileSync6
|
|
1856
1888
|
} from "fs";
|
|
1857
|
-
import { dirname as dirname4, join as
|
|
1889
|
+
import { dirname as dirname4, join as join5, relative, sep } from "path";
|
|
1858
1890
|
var MANIFEST_FILE = "manifest.json";
|
|
1859
1891
|
function projectDocumentsDir(apmRoot) {
|
|
1860
|
-
return
|
|
1892
|
+
return join5(apmRoot ?? workspaceApmDir(), "project");
|
|
1861
1893
|
}
|
|
1862
1894
|
function projectDocumentLocalPath(apmRoot, documentPath) {
|
|
1863
1895
|
const normalized = normalizeLocalDocumentPath(documentPath);
|
|
1864
|
-
return
|
|
1896
|
+
return join5(projectDocumentsDir(apmRoot), ...normalized.split("/"));
|
|
1865
1897
|
}
|
|
1866
1898
|
function normalizeLocalDocumentPath(path) {
|
|
1867
1899
|
const trimmed = path.trim().replace(/\\/g, "/");
|
|
@@ -1875,7 +1907,7 @@ function normalizeLocalDocumentPath(path) {
|
|
|
1875
1907
|
return segments.join("/");
|
|
1876
1908
|
}
|
|
1877
1909
|
function readLocalManifest(apmRoot) {
|
|
1878
|
-
const manifestPath =
|
|
1910
|
+
const manifestPath = join5(projectDocumentsDir(apmRoot), MANIFEST_FILE);
|
|
1879
1911
|
if (!existsSync4(manifestPath)) {
|
|
1880
1912
|
return null;
|
|
1881
1913
|
}
|
|
@@ -1971,7 +2003,7 @@ ${diagnostic ?? ""}`
|
|
|
1971
2003
|
}
|
|
1972
2004
|
}
|
|
1973
2005
|
writeFileSync6(
|
|
1974
|
-
toFsPath(
|
|
2006
|
+
toFsPath(join5(projectDir, MANIFEST_FILE)),
|
|
1975
2007
|
`${JSON.stringify(remoteManifest, null, 2)}
|
|
1976
2008
|
`,
|
|
1977
2009
|
"utf8"
|
|
@@ -2006,7 +2038,7 @@ async function ensureWorkspaceInitialized(workdir, options) {
|
|
|
2006
2038
|
await syncRepositoryProjectDocumentsPull(workdir, apmDir);
|
|
2007
2039
|
const trimmedName = options?.name?.trim();
|
|
2008
2040
|
if (trimmedName) {
|
|
2009
|
-
const apmConfigPath = toFsPath(
|
|
2041
|
+
const apmConfigPath = toFsPath(join6(apmDir, "apm.config.json"));
|
|
2010
2042
|
const config = readFileSync6(apmConfigPath, "utf8");
|
|
2011
2043
|
const configJson = JSON.parse(config);
|
|
2012
2044
|
configJson.name = trimmedName;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-project-manage-cli",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.5",
|
|
4
4
|
"description": "命令行工具:后续用于调用平台后端 API 完成运维与自动化操作",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@types/ssh2-sftp-client": "~9.0.6"
|
|
30
30
|
},
|
|
31
31
|
"engines": {
|
|
32
|
-
"node": ">=22.
|
|
32
|
+
"node": ">=22.0.0"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@bufbuild/protobuf": "1.10.0",
|