ai-project-manage-cli 1.0.29 → 2.0.1
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/api/cli.d.ts +30 -0
- package/dist/api/cli.d.ts.map +1 -0
- package/dist/api/cli.js +3 -0
- package/dist/api/cli.js.map +1 -0
- package/dist/api/client.d.ts +10 -4
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +7 -4
- package/dist/api/client.js.map +1 -1
- package/dist/api/index.d.ts +3 -3
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +4 -4
- package/dist/api/index.js.map +1 -1
- package/dist/api/request-config.d.ts +6 -15
- package/dist/api/request-config.d.ts.map +1 -1
- package/dist/api/request-config.js +8 -41
- package/dist/api/request-config.js.map +1 -1
- package/dist/api/requirement.d.ts +0 -133
- package/dist/api/requirement.d.ts.map +1 -1
- package/dist/api/requirement.js +0 -4
- package/dist/api/requirement.js.map +1 -1
- package/dist/cli/commands/auth.d.ts.map +1 -1
- package/dist/cli/commands/auth.js +32 -51
- package/dist/cli/commands/auth.js.map +1 -1
- package/dist/cli/commands/config.d.ts.map +1 -1
- package/dist/cli/commands/config.js +12 -48
- package/dist/cli/commands/config.js.map +1 -1
- package/dist/cli/commands/publish.d.ts.map +1 -1
- package/dist/cli/commands/publish.js +3 -16
- package/dist/cli/commands/publish.js.map +1 -1
- package/dist/cli/commands/update.d.ts.map +1 -1
- package/dist/cli/commands/update.js +2 -2
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/cli/commands/ws.d.ts.map +1 -1
- package/dist/cli/commands/ws.js +4 -73
- package/dist/cli/commands/ws.js.map +1 -1
- package/dist/cli/exit-api-error.d.ts.map +1 -1
- package/dist/cli/exit-api-error.js +6 -0
- package/dist/cli/exit-api-error.js.map +1 -1
- package/dist/cli.js +6 -38
- package/dist/cli.js.map +1 -1
- package/dist/core/apm-config.d.ts +27 -0
- package/dist/core/apm-config.d.ts.map +1 -0
- package/dist/core/apm-config.js +71 -0
- package/dist/core/apm-config.js.map +1 -0
- package/dist/core/constants.d.ts +4 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/constants.js +7 -0
- package/dist/core/constants.js.map +1 -0
- package/dist/core/cursor-cmd.d.ts +23 -0
- package/dist/core/cursor-cmd.d.ts.map +1 -0
- package/dist/core/cursor-cmd.js +137 -0
- package/dist/core/cursor-cmd.js.map +1 -0
- package/dist/core/std-event-handler.d.ts +25 -0
- package/dist/core/std-event-handler.d.ts.map +1 -0
- package/dist/core/std-event-handler.js +90 -0
- package/dist/core/std-event-handler.js.map +1 -0
- package/dist/core/utils.d.ts +18 -0
- package/dist/core/utils.d.ts.map +1 -0
- package/dist/core/utils.js +61 -0
- package/dist/core/utils.js.map +1 -0
- package/dist/core/ws-client.d.ts +24 -0
- package/dist/core/ws-client.d.ts.map +1 -0
- package/dist/core/ws-client.js +79 -0
- package/dist/core/ws-client.js.map +1 -0
- package/package.json +3 -3
- package/templates/skills/apm-auto-dev/SKILL.md +73 -16
- package/templates/skills/requirement-review/SKILL.md +12 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/cli/commands/config.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/cli/commands/config.ts"],"names":[],"mappings":";;AAOA,wDAiBC;AAvBD,sDAI+B;AAE/B,SAAgB,sBAAsB,CAAC,OAAgB;IACrD,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAEnE,SAAS;SACN,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,2BAA2B,CAAC;SACxC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;SACxB,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC;SAC9B,MAAM,CAAC,KAAK,EAAE,EAAU,EAAE,IAAsB,EAAE,EAAE;QACnD,IAAI,IAAA,8BAAiB,GAAE,EAAE,CAAC;YACxB,MAAM,IAAA,0BAAa,GAAE,CAAC;YACtB,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QACjC,CAAC;aAAM,CAAC;YACN,MAAM,IAAA,4BAAe,EAAC,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;YACzD,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/publish.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/publish.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgCzC,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAgH9D"}
|
|
@@ -7,8 +7,7 @@ exports.registerPublishCommands = registerPublishCommands;
|
|
|
7
7
|
const promises_1 = require("node:fs/promises");
|
|
8
8
|
const node_path_1 = __importDefault(require("node:path"));
|
|
9
9
|
const minio_1 = require("minio");
|
|
10
|
-
const
|
|
11
|
-
const config_store_1 = require("../../config-store");
|
|
10
|
+
const apm_config_1 = require("../../core/apm-config");
|
|
12
11
|
const MIME_BY_EXT = {
|
|
13
12
|
".html": "text/html; charset=utf-8",
|
|
14
13
|
".js": "application/javascript; charset=utf-8",
|
|
@@ -37,19 +36,7 @@ function registerPublishCommands(program) {
|
|
|
37
36
|
.option("--dir <dir>", "产物目录(默认 dist)", "dist")
|
|
38
37
|
.option("--max-file-size-mb <mb>", `单文件大小上限,默认 ${DEFAULT_MAX_FILE_SIZE_MB}`, (v) => Number.parseInt(String(v), 10))
|
|
39
38
|
.action(async (name, opts) => {
|
|
40
|
-
const
|
|
41
|
-
if (!resolved.ok) {
|
|
42
|
-
console.error(resolved.error);
|
|
43
|
-
const envPath = (0, apm_dotenv_1.getLoadedApmDotEnvPath)();
|
|
44
|
-
if (envPath) {
|
|
45
|
-
console.error(`已加载:${envPath}`);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
console.error("未找到当前目录下 `.apm/.env`;请在运行目录放置该文件,或在 shell 中先 export MINIO_*");
|
|
49
|
-
}
|
|
50
|
-
process.exit(1);
|
|
51
|
-
}
|
|
52
|
-
const { settings } = resolved;
|
|
39
|
+
const { deploy: settings } = (0, apm_config_1.loadApmConfig)();
|
|
53
40
|
const client = new minio_1.Client({
|
|
54
41
|
endPoint: settings.endpoint,
|
|
55
42
|
port: settings.port,
|
|
@@ -151,7 +138,7 @@ async function deleteObjectsByPrefix(client, bucket, prefix) {
|
|
|
151
138
|
for (;;) {
|
|
152
139
|
const result = await client.listObjectsV2Query(bucket, prefix, continuationToken, "", LIST_OBJECTS_PAGE_MAX_KEYS, "");
|
|
153
140
|
const keys = result.objects
|
|
154
|
-
.map((obj) => "name" in obj && obj.name ? obj.name.trim() : "")
|
|
141
|
+
.map((obj) => ("name" in obj && obj.name ? obj.name.trim() : ""))
|
|
155
142
|
.filter((name) => name.length > 0);
|
|
156
143
|
for (let i = 0; i < keys.length; i += removeBatchSize) {
|
|
157
144
|
await client.removeObjects(bucket, keys.slice(i, i + removeBatchSize));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../../../src/cli/commands/publish.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../../../src/cli/commands/publish.ts"],"names":[],"mappings":";;;;;AAkCA,0DAgHC;AAlJD,+CAA2D;AAC3D,0DAA6B;AAE7B,iCAA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;IAC1D,CAAC;AACH,CAAC;AAED,SAAS,mBAAmB,CAAC,GAAW;IACtC,MAAM,UAAU,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACtE,IAAI,CAAC,UAAU;QAAE,OAAO,EAAE,CAAC;IAC3B,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC;IACrE,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AACrC,CAAC;AAED,SAAS,cAAc,CAAC,QAAgB;IACtC,MAAM,GAAG,GAAG,mBAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC;IACjD,OAAO,WAAW,CAAC,GAAG,CAAC,IAAI,0BAA0B,CAAC;AACxD,CAAC;AAED,SAAS,IAAI,CAAC,KAAa;IACzB,OAAO,CAAC,KAAK,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/update.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOzC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/update.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOzC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA4B7D"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.registerUpdateCommands = registerUpdateCommands;
|
|
4
4
|
const node_child_process_1 = require("node:child_process");
|
|
5
|
-
const
|
|
5
|
+
const constants_1 = require("../../core/constants");
|
|
6
6
|
function npmExecutable() {
|
|
7
7
|
return process.platform === "win32" ? "npm.cmd" : "npm";
|
|
8
8
|
}
|
|
@@ -11,7 +11,7 @@ function registerUpdateCommands(program) {
|
|
|
11
11
|
.command("update")
|
|
12
12
|
.description("通过 npm 全局安装本 CLI 的最新版本(npm install -g <name>@latest)")
|
|
13
13
|
.action(async () => {
|
|
14
|
-
const name =
|
|
14
|
+
const name = constants_1.PACKAGE_NAME;
|
|
15
15
|
const args = ["install", "-g", `${name}@latest`];
|
|
16
16
|
const child = (0, node_child_process_1.spawn)(npmExecutable(), args, {
|
|
17
17
|
stdio: "inherit",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/cli/commands/update.ts"],"names":[],"mappings":";;AAQA,
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/cli/commands/update.ts"],"names":[],"mappings":";;AAQA,wDA4BC;AApCD,2DAA2C;AAE3C,oDAAoD;AAEpD,SAAS,aAAa;IACpB,OAAO,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC;AAC1D,CAAC;AAED,SAAgB,sBAAsB,CAAC,OAAgB;IACrD,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CACV,sDAAsD,CACvD;SACA,MAAM,CAAC,KAAK,IAAI,EAAE;QACjB,MAAM,IAAI,GAAG,wBAAY,CAAC;QAC1B,MAAM,IAAI,GAAG,CAAC,SAAS,EAAE,IAAI,EAAE,GAAG,IAAI,SAAS,CAAC,CAAC;QACjD,MAAM,KAAK,GAAG,IAAA,0BAAK,EAAC,aAAa,EAAE,EAAE,IAAI,EAAE;YACzC,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,KAAK;SACb,CAAC,CAAC;QACH,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC1C,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAC1B,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;gBACjC,IAAI,MAAM,EAAE,CAAC;oBACX,MAAM,CAAC,IAAI,KAAK,CAAC,cAAc,MAAM,EAAE,CAAC,CAAC,CAAC;oBAC1C,OAAO;gBACT,CAAC;gBACD,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;oBACf,OAAO,EAAE,CAAC;oBACV,OAAO;gBACT,CAAC;gBACD,MAAM,CAAC,IAAI,KAAK,CAAC,WAAW,IAAI,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC;YACpD,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/ws.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/ws.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAoBzD"}
|
package/dist/cli/commands/ws.js
CHANGED
|
@@ -1,82 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.registerWsCommands = registerWsCommands;
|
|
4
|
-
const
|
|
5
|
-
const employee_ws_client_1 = require("../../employee-ws-client");
|
|
6
|
-
const config_store_1 = require("../../config-store");
|
|
7
|
-
const ws_run_command_1 = require("../ws-run-command");
|
|
4
|
+
const ws_client_1 = require("../../core/ws-client");
|
|
8
5
|
function registerWsCommands(program) {
|
|
9
|
-
|
|
6
|
+
program
|
|
10
7
|
.command("ws")
|
|
11
8
|
.description("启动员工 WebSocket 客户端,连接后等待服务端推送(Ctrl+C 退出)。可通过 --token 直接传入")
|
|
12
|
-
.
|
|
13
|
-
|
|
14
|
-
.option("--token <token>", "员工 WebSocket token(优先级最高;不再依赖配置文件的 token)")
|
|
15
|
-
.option("-u, --url <url>", "服务根地址(覆盖配置中的 base-url)")
|
|
16
|
-
.option("--employee-id <id>", "员工 id(仅用于日志显示;可选)", (v) => Number.parseInt(String(v), 10))
|
|
17
|
-
.action((opts) => {
|
|
18
|
-
if (opts.version) {
|
|
19
|
-
console.log((0, cli_version_1.getCliPackageVersion)());
|
|
20
|
-
process.exit(0);
|
|
21
|
-
}
|
|
22
|
-
const cfg = (0, config_store_1.readApmConfigSync)();
|
|
23
|
-
const baseUrlRaw = opts.url?.trim() || cfg.baseUrl?.trim() || "";
|
|
24
|
-
const baseUrl = baseUrlRaw ? (0, config_store_1.normalizeBaseUrl)(baseUrlRaw) : "";
|
|
25
|
-
if (!baseUrl) {
|
|
26
|
-
console.error("缺少服务根地址:请传入 --url <url>,或先执行 apm config set base-url <url>");
|
|
27
|
-
process.exit(1);
|
|
28
|
-
}
|
|
29
|
-
const token = (opts.token?.trim() || cfg.token?.trim() || "").trim();
|
|
30
|
-
if (!token) {
|
|
31
|
-
console.error("缺少 token:请传入 --token <token>,或先执行 apm login 写入配置文件");
|
|
32
|
-
process.exit(1);
|
|
33
|
-
}
|
|
34
|
-
const employeeIdRaw = opts.employeeId != null && Number.isFinite(opts.employeeId)
|
|
35
|
-
? opts.employeeId
|
|
36
|
-
: cfg.employeeId;
|
|
37
|
-
const employeeId = typeof employeeIdRaw === "number" && Number.isFinite(employeeIdRaw)
|
|
38
|
-
? employeeIdRaw
|
|
39
|
-
: undefined;
|
|
40
|
-
let wsPort;
|
|
41
|
-
if (opts.port !== undefined) {
|
|
42
|
-
if (!Number.isFinite(opts.port) ||
|
|
43
|
-
opts.port < 1 ||
|
|
44
|
-
opts.port > 65535) {
|
|
45
|
-
console.error("--port 须为 1–65535 的整数");
|
|
46
|
-
process.exit(1);
|
|
47
|
-
}
|
|
48
|
-
wsPort = Math.floor(opts.port);
|
|
49
|
-
}
|
|
50
|
-
const u = new URL(baseUrl);
|
|
51
|
-
const effectivePort = wsPort ?? (0, config_store_1.resolveEmployeeWsPortFromConfig)();
|
|
52
|
-
const wsProto = u.protocol === "https:" ? "wss:" : "ws:";
|
|
53
|
-
console.error(`连接 ${wsProto}//${u.hostname}:${effectivePort}/ws(员工 id=${employeeId ?? "unknown"})…`);
|
|
54
|
-
const ws = (0, employee_ws_client_1.createEmployeeWebSocket)({
|
|
55
|
-
baseUrl,
|
|
56
|
-
token,
|
|
57
|
-
wsPort,
|
|
58
|
-
onOpen: () => {
|
|
59
|
-
console.error("已连接,等待服务端推送…");
|
|
60
|
-
},
|
|
61
|
-
onMessage: (_raw, parsed) => {
|
|
62
|
-
if (parsed?.event === "cursor") {
|
|
63
|
-
(0, ws_run_command_1.runCursorFromServerPayload)(parsed.data);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
if (parsed) {
|
|
67
|
-
console.log(JSON.stringify(parsed, null, 2));
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
console.log(_raw);
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
onClose: (code, reason) => {
|
|
74
|
-
console.error(`连接关闭 code=${code} ${reason.toString()}`);
|
|
75
|
-
},
|
|
76
|
-
onError: (err) => {
|
|
77
|
-
console.error(err.message);
|
|
78
|
-
},
|
|
79
|
-
});
|
|
9
|
+
.action(() => {
|
|
10
|
+
const ws = new ws_client_1.EmployeeWebSocketClient();
|
|
80
11
|
const shutdown = () => {
|
|
81
12
|
try {
|
|
82
13
|
ws.close();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws.js","sourceRoot":"","sources":["../../../src/cli/commands/ws.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"ws.js","sourceRoot":"","sources":["../../../src/cli/commands/ws.ts"],"names":[],"mappings":";;AAGA,gDAoBC;AAtBD,oDAA+D;AAE/D,SAAgB,kBAAkB,CAAC,OAAgB;IACjD,OAAO;SACJ,OAAO,CAAC,IAAI,CAAC;SACb,WAAW,CACV,2DAA2D,CAC5D;SACA,MAAM,CAAC,GAAG,EAAE;QACX,MAAM,EAAE,GAAG,IAAI,mCAAuB,EAAE,CAAC;QAEzC,MAAM,QAAQ,GAAG,GAAG,EAAE;YACpB,IAAI,CAAC;gBACH,EAAE,CAAC,KAAK,EAAE,CAAC;YACb,CAAC;YAAC,MAAM,CAAC;gBACP,YAAY;YACd,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACjC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exit-api-error.d.ts","sourceRoot":"","sources":["../../src/cli/exit-api-error.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,KAAK,
|
|
1
|
+
{"version":3,"file":"exit-api-error.d.ts","sourceRoot":"","sources":["../../src/cli/exit-api-error.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,KAAK,CAchD"}
|
|
@@ -5,6 +5,12 @@ const listpage_http_1 = require("listpage-http");
|
|
|
5
5
|
function exitApiError(err) {
|
|
6
6
|
if (err instanceof listpage_http_1.ApiError) {
|
|
7
7
|
console.error(`接口错误 [${err.code}]: ${err.message}`);
|
|
8
|
+
if (err.code === -1) {
|
|
9
|
+
if (err.url) {
|
|
10
|
+
console.error(`请求: ${err.method ?? "GET"} ${err.url}`);
|
|
11
|
+
}
|
|
12
|
+
console.error("网络层失败(未收到 HTTP 响应)。请检查:1) 后端是否已启动;2) `apm config get base-url` 是否为可访问的根地址(含协议与端口,与浏览器能打开的地址一致);3) 本机代理/VPN/防火墙是否拦截。可执行 `apm login --url <正确根地址>` 后重试。");
|
|
13
|
+
}
|
|
8
14
|
process.exit(1);
|
|
9
15
|
}
|
|
10
16
|
throw err;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exit-api-error.js","sourceRoot":"","sources":["../../src/cli/exit-api-error.ts"],"names":[],"mappings":";;AAEA,
|
|
1
|
+
{"version":3,"file":"exit-api-error.js","sourceRoot":"","sources":["../../src/cli/exit-api-error.ts"],"names":[],"mappings":";;AAEA,oCAcC;AAhBD,iDAAyC;AAEzC,SAAgB,YAAY,CAAC,GAAY;IACvC,IAAI,GAAG,YAAY,wBAAQ,EAAE,CAAC;QAC5B,OAAO,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,IAAI,MAAM,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QACpD,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC;YACpB,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC;gBACZ,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,MAAM,IAAI,KAAK,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;YACzD,CAAC;YACD,OAAO,CAAC,KAAK,CACX,uJAAuJ,CACxJ,CAAC;QACJ,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,MAAM,GAAG,CAAC;AACZ,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -2,55 +2,23 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const commander_1 = require("commander");
|
|
5
|
-
const config_store_1 = require("./config-store");
|
|
6
5
|
const auth_1 = require("./cli/commands/auth");
|
|
7
|
-
const chat_1 = require("./cli/commands/chat");
|
|
8
|
-
const comment_1 = require("./cli/commands/comment");
|
|
9
6
|
const config_1 = require("./cli/commands/config");
|
|
10
7
|
const init_1 = require("./cli/commands/init");
|
|
11
8
|
const publish_1 = require("./cli/commands/publish");
|
|
12
|
-
const requirement_1 = require("./cli/commands/requirement");
|
|
13
9
|
const update_1 = require("./cli/commands/update");
|
|
14
10
|
const ws_1 = require("./cli/commands/ws");
|
|
15
|
-
const
|
|
16
|
-
const cli_version_1 = require("./cli-version");
|
|
11
|
+
const constants_1 = require("./core/constants");
|
|
17
12
|
const program = new commander_1.Command()
|
|
18
13
|
.name("apm")
|
|
19
|
-
.description(
|
|
20
|
-
.version(
|
|
21
|
-
.hook("preAction", () => {
|
|
22
|
-
const argv = process.argv.slice(2);
|
|
23
|
-
if (argv.includes("--version") || argv.includes("-V")) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
const first = argv.find((a) => !a.startsWith("-"));
|
|
27
|
-
if (first === "config" ||
|
|
28
|
-
first === "init" ||
|
|
29
|
-
first === "login" ||
|
|
30
|
-
first === "logout" ||
|
|
31
|
-
first === "update" ||
|
|
32
|
-
first === "ws" ||
|
|
33
|
-
first === "chat" ||
|
|
34
|
-
first === "publish") {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
const cred = (0, credentials_1.resolveEffectiveCredentials)();
|
|
38
|
-
if ("error" in cred) {
|
|
39
|
-
console.error(cred.error);
|
|
40
|
-
console.error(`配置文件:${(0, config_store_1.getApmConfigPath)()}`);
|
|
41
|
-
process.exit(1);
|
|
42
|
-
}
|
|
43
|
-
(0, credentials_1.setActiveCliCredentials)(cred);
|
|
44
|
-
});
|
|
14
|
+
.description(constants_1.PACKAGE_DESCRIPTION)
|
|
15
|
+
.version(constants_1.PACKAGE_VERSION);
|
|
45
16
|
(0, config_1.registerConfigCommands)(program);
|
|
46
|
-
(0, init_1.registerInitCommands)(program);
|
|
47
17
|
(0, auth_1.registerAuthCommands)(program);
|
|
48
|
-
(0, chat_1.registerChatCommands)(program);
|
|
49
|
-
(0, comment_1.registerCommentCommands)(program);
|
|
50
|
-
(0, publish_1.registerPublishCommands)(program);
|
|
51
|
-
(0, requirement_1.registerRequirementCommands)(program);
|
|
52
|
-
(0, update_1.registerUpdateCommands)(program);
|
|
53
18
|
(0, ws_1.registerWsCommands)(program);
|
|
19
|
+
(0, update_1.registerUpdateCommands)(program);
|
|
20
|
+
(0, init_1.registerInitCommands)(program);
|
|
21
|
+
(0, publish_1.registerPublishCommands)(program);
|
|
54
22
|
program.parseAsync(process.argv).catch((err) => {
|
|
55
23
|
console.error(err);
|
|
56
24
|
process.exit(1);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AACA,yCAAoC;AACpC,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AACA,yCAAoC;AACpC,8CAA2D;AAC3D,kDAA+D;AAC/D,8CAA2D;AAC3D,oDAAiE;AACjE,kDAA+D;AAC/D,0CAAuD;AACvD,gDAAwE;AAExE,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE;KAC1B,IAAI,CAAC,KAAK,CAAC;KACX,WAAW,CAAC,+BAAmB,CAAC;KAChC,OAAO,CAAC,2BAAe,CAAC,CAAC;AAE5B,IAAA,+BAAsB,EAAC,OAAO,CAAC,CAAC;AAChC,IAAA,2BAAoB,EAAC,OAAO,CAAC,CAAC;AAC9B,IAAA,uBAAkB,EAAC,OAAO,CAAC,CAAC;AAC5B,IAAA,+BAAsB,EAAC,OAAO,CAAC,CAAC;AAChC,IAAA,2BAAoB,EAAC,OAAO,CAAC,CAAC;AAC9B,IAAA,iCAAuB,EAAC,OAAO,CAAC,CAAC;AAEjC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IAC7C,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type ApmConfig = {
|
|
2
|
+
auth: {
|
|
3
|
+
id: number;
|
|
4
|
+
token: string;
|
|
5
|
+
};
|
|
6
|
+
server: {
|
|
7
|
+
url: string;
|
|
8
|
+
wsPort: number;
|
|
9
|
+
};
|
|
10
|
+
deploy: {
|
|
11
|
+
endpoint: string;
|
|
12
|
+
port: number;
|
|
13
|
+
useSsl: boolean;
|
|
14
|
+
bucket: string;
|
|
15
|
+
accessKey: string;
|
|
16
|
+
secretKey: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export declare function loadApmConfig(): ApmConfig;
|
|
20
|
+
export declare function syncApmConfig(): Promise<void>;
|
|
21
|
+
export declare function isApmConfigExists(): boolean;
|
|
22
|
+
export declare function saveApmToken(token: string): void;
|
|
23
|
+
export declare function createApmConfig(options: {
|
|
24
|
+
id: number;
|
|
25
|
+
url?: string;
|
|
26
|
+
}): Promise<void>;
|
|
27
|
+
//# sourceMappingURL=apm-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apm-config.d.ts","sourceRoot":"","sources":["../../src/core/apm-config.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE;QAEJ,EAAE,EAAE,MAAM,CAAC;QAEX,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,MAAM,EAAE;QAEN,GAAG,EAAE,MAAM,CAAC;QAEZ,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,MAAM,EAAE;QACN,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,OAAO,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH,CAAC;AAEF,wBAAgB,aAAa,IAAI,SAAS,CAazC;AAGD,wBAAsB,aAAa,kBAMlC;AAMD,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,QAKzC;AAED,wBAAsB,eAAe,CAAC,OAAO,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,iBA2B1E"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.loadApmConfig = loadApmConfig;
|
|
7
|
+
exports.syncApmConfig = syncApmConfig;
|
|
8
|
+
exports.isApmConfigExists = isApmConfigExists;
|
|
9
|
+
exports.saveApmToken = saveApmToken;
|
|
10
|
+
exports.createApmConfig = createApmConfig;
|
|
11
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
12
|
+
const node_fs_1 = require("node:fs");
|
|
13
|
+
const node_process_1 = require("node:process");
|
|
14
|
+
const client_1 = __importDefault(require("../api/client"));
|
|
15
|
+
function loadApmConfig() {
|
|
16
|
+
try {
|
|
17
|
+
const p = getApmConfigPath();
|
|
18
|
+
if (!(0, node_fs_1.existsSync)(p)) {
|
|
19
|
+
console.error("配置文件不存在,请确保当前目录下存在 apm.config.json");
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
const j = JSON.parse((0, node_fs_1.readFileSync)(p, "utf8"));
|
|
23
|
+
return j;
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
console.error(e);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// 同步远程的配置项到本地
|
|
31
|
+
async function syncApmConfig() {
|
|
32
|
+
const p = getApmConfigPath();
|
|
33
|
+
const cfg = loadApmConfig();
|
|
34
|
+
const res = await client_1.default.cli.variablesGet();
|
|
35
|
+
const j = JSON.stringify({ ...cfg, ...res }, null, 2);
|
|
36
|
+
(0, node_fs_1.writeFileSync)(p, j);
|
|
37
|
+
}
|
|
38
|
+
function getApmConfigPath() {
|
|
39
|
+
return node_path_1.default.join((0, node_process_1.cwd)(), ".apm/apm.config.json");
|
|
40
|
+
}
|
|
41
|
+
function isApmConfigExists() {
|
|
42
|
+
return (0, node_fs_1.existsSync)(getApmConfigPath());
|
|
43
|
+
}
|
|
44
|
+
function saveApmToken(token) {
|
|
45
|
+
const p = getApmConfigPath();
|
|
46
|
+
const currentConfig = loadApmConfig();
|
|
47
|
+
currentConfig.auth.token = token;
|
|
48
|
+
(0, node_fs_1.writeFileSync)(p, JSON.stringify(currentConfig, null, 2));
|
|
49
|
+
}
|
|
50
|
+
async function createApmConfig(options) {
|
|
51
|
+
const p = getApmConfigPath();
|
|
52
|
+
(0, node_fs_1.writeFileSync)(p, JSON.stringify({
|
|
53
|
+
auth: {
|
|
54
|
+
id: options.id,
|
|
55
|
+
token: "",
|
|
56
|
+
},
|
|
57
|
+
server: {
|
|
58
|
+
url: options.url || "http://localhost:3000",
|
|
59
|
+
wsPort: 4000,
|
|
60
|
+
},
|
|
61
|
+
deploy: {
|
|
62
|
+
endpoint: "",
|
|
63
|
+
port: 0,
|
|
64
|
+
useSsl: false,
|
|
65
|
+
bucket: "",
|
|
66
|
+
accessKey: "",
|
|
67
|
+
secretKey: "",
|
|
68
|
+
},
|
|
69
|
+
}, null, 2));
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=apm-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apm-config.js","sourceRoot":"","sources":["../../src/core/apm-config.ts"],"names":[],"mappings":";;;;;AA4BA,sCAaC;AAGD,sCAMC;AAMD,8CAEC;AAED,oCAKC;AAED,0CA2BC;AA9FD,0DAA6B;AAC7B,qCAAkE;AAClE,+CAAmC;AACnC,2DAAgC;AAyBhC,SAAgB,aAAa;IAC3B,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,gBAAgB,EAAE,CAAC;QAC7B,IAAI,CAAC,IAAA,oBAAU,EAAC,CAAC,CAAC,EAAE,CAAC;YACnB,OAAO,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;YACpD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,sBAAY,EAAC,CAAC,EAAE,MAAM,CAAC,CAAc,CAAC;QAC3D,OAAO,CAAC,CAAC;IACX,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,cAAc;AACP,KAAK,UAAU,aAAa;IACjC,MAAM,CAAC,GAAG,gBAAgB,EAAE,CAAC;IAC7B,MAAM,GAAG,GAAG,aAAa,EAAE,CAAC;IAC5B,MAAM,GAAG,GAAG,MAAM,gBAAG,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC;IACzC,MAAM,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,GAAG,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
|
|
2
|
+
export declare const PACKAGE_NAME = "ai-project-manage-cli";
|
|
3
|
+
export declare const PACKAGE_DESCRIPTION = "AI \u9879\u76EE\u7BA1\u7406 CLI \u5DE5\u5177\uFF0C\u7ED3\u5408\u98DE\u4E66\u9879\u76EE\u5B9E\u73B0AI\u9879\u76EE\u5F00\u53D1\u5DE5\u4F5C\u6D41";
|
|
4
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/core/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,UAAU,CAAC;AACvC,eAAO,MAAM,YAAY,0BAA0B,CAAC;AACpD,eAAO,MAAM,mBAAmB,mJACI,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PACKAGE_DESCRIPTION = exports.PACKAGE_NAME = exports.PACKAGE_VERSION = void 0;
|
|
4
|
+
exports.PACKAGE_VERSION = "2.0.1";
|
|
5
|
+
exports.PACKAGE_NAME = "ai-project-manage-cli";
|
|
6
|
+
exports.PACKAGE_DESCRIPTION = "AI 项目管理 CLI 工具,结合飞书项目实现AI项目开发工作流";
|
|
7
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/core/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,OAAO,CAAC;AAC1B,QAAA,YAAY,GAAG,uBAAuB,CAAC;AACvC,QAAA,mBAAmB,GAC9B,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type CursorCmdPayload = {
|
|
2
|
+
prompt: string;
|
|
3
|
+
model?: string;
|
|
4
|
+
workdir: string;
|
|
5
|
+
chatId?: string;
|
|
6
|
+
requirementId: number;
|
|
7
|
+
};
|
|
8
|
+
export declare class CursorCmd {
|
|
9
|
+
private workdir;
|
|
10
|
+
private prompt;
|
|
11
|
+
private model?;
|
|
12
|
+
private chatId?;
|
|
13
|
+
private name;
|
|
14
|
+
private requirementId;
|
|
15
|
+
constructor(payload: CursorCmdPayload);
|
|
16
|
+
execute(): void;
|
|
17
|
+
private buildArgs;
|
|
18
|
+
private runPrompt;
|
|
19
|
+
private createChat;
|
|
20
|
+
private execCommand;
|
|
21
|
+
private execCommandSync;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=cursor-cmd.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor-cmd.d.ts","sourceRoot":"","sources":["../../src/core/cursor-cmd.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAEhB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,qBAAa,SAAS;IACpB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,KAAK,CAAC,CAAS;IACvB,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,aAAa,CAAS;gBAElB,OAAO,EAAE,gBAAgB;IAUrC,OAAO;IAaP,OAAO,CAAC,SAAS;IAwBjB,OAAO,CAAC,SAAS;IAuBjB,OAAO,CAAC,UAAU;IAkClB,OAAO,CAAC,WAAW;IAgBnB,OAAO,CAAC,eAAe;CAexB"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CursorCmd = void 0;
|
|
4
|
+
const node_child_process_1 = require("node:child_process");
|
|
5
|
+
const std_event_handler_1 = require("./std-event-handler");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
class CursorCmd {
|
|
8
|
+
workdir;
|
|
9
|
+
prompt;
|
|
10
|
+
model;
|
|
11
|
+
chatId;
|
|
12
|
+
name;
|
|
13
|
+
requirementId;
|
|
14
|
+
constructor(payload) {
|
|
15
|
+
this.workdir = payload.workdir;
|
|
16
|
+
const cleaned = (0, utils_1.cleanPrompt)(payload.prompt);
|
|
17
|
+
this.name = cleaned.headToken;
|
|
18
|
+
this.prompt = cleaned.bodyWithoutHead;
|
|
19
|
+
this.model = payload.model;
|
|
20
|
+
this.requirementId = payload.requirementId;
|
|
21
|
+
this.chatId = payload.chatId;
|
|
22
|
+
}
|
|
23
|
+
execute() {
|
|
24
|
+
if (!this.chatId) {
|
|
25
|
+
this.chatId = this.createChat();
|
|
26
|
+
}
|
|
27
|
+
if (!this.chatId) {
|
|
28
|
+
console.error("命令执行失败");
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const argv = this.buildArgs();
|
|
32
|
+
return this.runPrompt(argv);
|
|
33
|
+
}
|
|
34
|
+
// 处理参数
|
|
35
|
+
buildArgs() {
|
|
36
|
+
const args = [];
|
|
37
|
+
if (this.model) {
|
|
38
|
+
args.push("--model", this.model);
|
|
39
|
+
}
|
|
40
|
+
if (this.workdir) {
|
|
41
|
+
args.push("--workspace", this.workdir);
|
|
42
|
+
}
|
|
43
|
+
if (this.chatId) {
|
|
44
|
+
args.push("--resume", this.chatId);
|
|
45
|
+
}
|
|
46
|
+
return [
|
|
47
|
+
"-f",
|
|
48
|
+
"-p",
|
|
49
|
+
...args,
|
|
50
|
+
"--trust",
|
|
51
|
+
"--output-format",
|
|
52
|
+
"stream-json",
|
|
53
|
+
"--stream-partial-output",
|
|
54
|
+
(0, utils_1.escapePromptForCliArg)(this.prompt),
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
// 执行提示词
|
|
58
|
+
runPrompt(args) {
|
|
59
|
+
const child = this.execCommand("agent", args);
|
|
60
|
+
const stdoutEventHandler = new std_event_handler_1.StdoutEventHandler((ev) => {
|
|
61
|
+
console.log(ev);
|
|
62
|
+
});
|
|
63
|
+
const stderrEventHandler = new std_event_handler_1.StderrEventHandler((ev) => {
|
|
64
|
+
console.log(ev);
|
|
65
|
+
});
|
|
66
|
+
const childProcessEventHandler = new std_event_handler_1.ChildProcessEventHandler(this.name, (ev) => {
|
|
67
|
+
console.log(ev);
|
|
68
|
+
});
|
|
69
|
+
child.stdout?.on("data", stdoutEventHandler.onData);
|
|
70
|
+
child.stdout?.on("end", stdoutEventHandler.onEnd);
|
|
71
|
+
child.stderr?.on("data", stderrEventHandler.onData);
|
|
72
|
+
child.stderr?.on("end", stderrEventHandler.onEnd);
|
|
73
|
+
child.on("close", childProcessEventHandler.onClose);
|
|
74
|
+
child.on("error", childProcessEventHandler.onError);
|
|
75
|
+
}
|
|
76
|
+
// 创建会话
|
|
77
|
+
createChat() {
|
|
78
|
+
const result = this.execCommandSync("agent", ["create-chat"]);
|
|
79
|
+
if (result.error) {
|
|
80
|
+
console.error(`创建会话失败: ${result.error.message}`);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (typeof result.status === "number" && result.status !== 0) {
|
|
84
|
+
const stderr = String(result.stderr ?? "").trim();
|
|
85
|
+
console.error(`创建会话失败: ${stderr || `exit code ${result.status}`}`);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const output = String(result.stdout ?? "").trim();
|
|
89
|
+
if (!output) {
|
|
90
|
+
console.error("创建会话失败: 未获取到 chatId");
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
// 兼容命令输出中包含其他日志,取最后一个非空行作为 chatId。
|
|
94
|
+
const lines = output
|
|
95
|
+
.split(/\r?\n/)
|
|
96
|
+
.map((s) => s.trim())
|
|
97
|
+
.filter(Boolean);
|
|
98
|
+
const chatId = lines.at(-1) ?? "";
|
|
99
|
+
if (!chatId) {
|
|
100
|
+
console.error("创建会话失败: chatId 为空");
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
return chatId;
|
|
104
|
+
}
|
|
105
|
+
execCommand(command, args) {
|
|
106
|
+
const isWin = process.platform === "win32";
|
|
107
|
+
if (isWin) {
|
|
108
|
+
return (0, node_child_process_1.spawn)("cmd.exe", ["/d", "/s", "/c", command, ...args], {
|
|
109
|
+
cwd: this.workdir,
|
|
110
|
+
windowsVerbatimArguments: false,
|
|
111
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
return (0, node_child_process_1.spawn)(command, args, {
|
|
115
|
+
cwd: this.workdir,
|
|
116
|
+
shell: false,
|
|
117
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
execCommandSync(command, args) {
|
|
121
|
+
const isWin = process.platform === "win32";
|
|
122
|
+
if (isWin) {
|
|
123
|
+
return (0, node_child_process_1.spawnSync)("cmd.exe", ["/d", "/s", "/c", command, ...args], {
|
|
124
|
+
cwd: this.workdir,
|
|
125
|
+
windowsVerbatimArguments: false,
|
|
126
|
+
encoding: "utf8",
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return (0, node_child_process_1.spawnSync)(command, args, {
|
|
130
|
+
cwd: this.workdir,
|
|
131
|
+
shell: false,
|
|
132
|
+
encoding: "utf8",
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.CursorCmd = CursorCmd;
|
|
137
|
+
//# sourceMappingURL=cursor-cmd.js.map
|