ai-project-manage-cli 8.0.7 → 8.0.9
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 +132 -2
- package/dist/webide-message-worker.js +809 -50
- package/package.json +7 -6
- package/template/AGENTS.webide.md +1 -0
- package/template/rules/webide_package.md +75 -0
- package/template/rules/webide_sql_change.md +5 -3
- package/template/rules/webide_sql_execute.md +29 -0
- package/template/rules/webide_terminal.md +2 -2
package/dist/index.js
CHANGED
|
@@ -154,6 +154,14 @@ var init_request_config = __esm({
|
|
|
154
154
|
method: "PUT",
|
|
155
155
|
path: "/cli/webide/test-cases"
|
|
156
156
|
}),
|
|
157
|
+
webideUpsertSqlExecution: defineEndpoint({
|
|
158
|
+
method: "PUT",
|
|
159
|
+
path: "/cli/webide/sql-executions"
|
|
160
|
+
}),
|
|
161
|
+
webideFinalizeSqlExecution: defineEndpoint({
|
|
162
|
+
method: "PUT",
|
|
163
|
+
path: "/cli/webide/sql-executions/finalize"
|
|
164
|
+
}),
|
|
157
165
|
projectBaseBranch: defineEndpoint(
|
|
158
166
|
{
|
|
159
167
|
method: "GET",
|
|
@@ -187,6 +195,18 @@ var init_request_config = __esm({
|
|
|
187
195
|
getApmLogStorage: defineEndpoint({
|
|
188
196
|
method: "GET",
|
|
189
197
|
path: "/cli/apm-log-storage"
|
|
198
|
+
}),
|
|
199
|
+
projectPackageUpdateStatus: defineEndpoint({
|
|
200
|
+
method: "PUT",
|
|
201
|
+
path: "/cli/project-packages/status"
|
|
202
|
+
}),
|
|
203
|
+
projectPackageAppendContent: defineEndpoint({
|
|
204
|
+
method: "PUT",
|
|
205
|
+
path: "/cli/project-packages/content"
|
|
206
|
+
}),
|
|
207
|
+
projectPackageEnsureContent: defineEndpoint({
|
|
208
|
+
method: "PUT",
|
|
209
|
+
path: "/cli/project-packages/ensure-content"
|
|
190
210
|
})
|
|
191
211
|
}
|
|
192
212
|
};
|
|
@@ -1042,6 +1062,9 @@ init_config();
|
|
|
1042
1062
|
function isWebIdeStartProjectTarget(value) {
|
|
1043
1063
|
return value === "frontend" || value === "backend" || value === "mobile";
|
|
1044
1064
|
}
|
|
1065
|
+
function isWebIdePackageTarget(value) {
|
|
1066
|
+
return value === "frontend" || value === "backend";
|
|
1067
|
+
}
|
|
1045
1068
|
function nonEmptyString(v) {
|
|
1046
1069
|
return typeof v === "string" && v.trim().length > 0;
|
|
1047
1070
|
}
|
|
@@ -1178,13 +1201,64 @@ function validateWebIdeStartProjectPush(o) {
|
|
|
1178
1201
|
}
|
|
1179
1202
|
};
|
|
1180
1203
|
}
|
|
1204
|
+
function validateWebIdePackagePush(o) {
|
|
1205
|
+
if (o.type !== "webide-package") {
|
|
1206
|
+
return { ok: false, reason: "\u671F\u671B webide-package" };
|
|
1207
|
+
}
|
|
1208
|
+
if (!nonEmptyString(o.packageId)) {
|
|
1209
|
+
return { ok: false, reason: "webide-package \u7F3A\u5C11 packageId" };
|
|
1210
|
+
}
|
|
1211
|
+
if (!nonEmptyString(o.messageId)) {
|
|
1212
|
+
return { ok: false, reason: "webide-package \u7F3A\u5C11 messageId" };
|
|
1213
|
+
}
|
|
1214
|
+
if (!nonEmptyString(o.projectId)) {
|
|
1215
|
+
return { ok: false, reason: "webide-package \u7F3A\u5C11 projectId" };
|
|
1216
|
+
}
|
|
1217
|
+
if (!isWebIdePackageTarget(o.target)) {
|
|
1218
|
+
return { ok: false, reason: "webide-package \u7F3A\u5C11\u6709\u6548 target" };
|
|
1219
|
+
}
|
|
1220
|
+
if (!nonEmptyString(o.baseBranch)) {
|
|
1221
|
+
return { ok: false, reason: "webide-package \u7F3A\u5C11 baseBranch" };
|
|
1222
|
+
}
|
|
1223
|
+
if (!nonEmptyString(o.content)) {
|
|
1224
|
+
return { ok: false, reason: "webide-package \u7F3A\u5C11 content" };
|
|
1225
|
+
}
|
|
1226
|
+
if (!nonEmptyString(o.model)) {
|
|
1227
|
+
return { ok: false, reason: "webide-package \u7F3A\u5C11 model" };
|
|
1228
|
+
}
|
|
1229
|
+
if (!nonEmptyString(o.apiKey)) {
|
|
1230
|
+
return { ok: false, reason: "webide-package \u7F3A\u5C11 apiKey" };
|
|
1231
|
+
}
|
|
1232
|
+
if (!nonEmptyString(o.workdir)) {
|
|
1233
|
+
return { ok: false, reason: "webide-package \u7F3A\u5C11 workdir" };
|
|
1234
|
+
}
|
|
1235
|
+
if (!nonEmptyString(o.user)) {
|
|
1236
|
+
return { ok: false, reason: "webide-package \u7F3A\u5C11 user" };
|
|
1237
|
+
}
|
|
1238
|
+
return {
|
|
1239
|
+
ok: true,
|
|
1240
|
+
data: {
|
|
1241
|
+
type: "webide-package",
|
|
1242
|
+
packageId: o.packageId.trim(),
|
|
1243
|
+
messageId: o.messageId.trim(),
|
|
1244
|
+
projectId: o.projectId.trim(),
|
|
1245
|
+
target: o.target,
|
|
1246
|
+
baseBranch: o.baseBranch.trim().replace(/^origin\//, ""),
|
|
1247
|
+
content: o.content,
|
|
1248
|
+
model: o.model.trim(),
|
|
1249
|
+
apiKey: o.apiKey.trim(),
|
|
1250
|
+
workdir: o.workdir.trim(),
|
|
1251
|
+
user: o.user.trim()
|
|
1252
|
+
}
|
|
1253
|
+
};
|
|
1254
|
+
}
|
|
1181
1255
|
function validateAgentWsMessage(value, kind) {
|
|
1182
1256
|
if (typeof value !== "object" || value === null) {
|
|
1183
1257
|
return { ok: false, reason: "\u6D88\u606F\u4F53\u4E0D\u662F JSON \u5BF9\u8C61" };
|
|
1184
1258
|
}
|
|
1185
1259
|
const o = value;
|
|
1186
1260
|
const type = o.type;
|
|
1187
|
-
if (type !== "heartbeat" && type !== "webide-message" && type !== "cancel" && type !== "webide-start-project" && type !== "webide-stop-terminals") {
|
|
1261
|
+
if (type !== "heartbeat" && type !== "webide-message" && type !== "cancel" && type !== "webide-start-project" && type !== "webide-stop-terminals" && type !== "webide-package") {
|
|
1188
1262
|
return { ok: false, reason: `\u672A\u77E5 type: ${String(type)}` };
|
|
1189
1263
|
}
|
|
1190
1264
|
if (kind === "heartbeat" || type === "heartbeat") {
|
|
@@ -1199,6 +1273,9 @@ function validateAgentWsMessage(value, kind) {
|
|
|
1199
1273
|
if (type === "webide-stop-terminals") {
|
|
1200
1274
|
return validateWebIdeStopTerminals(o);
|
|
1201
1275
|
}
|
|
1276
|
+
if (type === "webide-package") {
|
|
1277
|
+
return validateWebIdePackagePush(o);
|
|
1278
|
+
}
|
|
1202
1279
|
return validateWebIdeMessagePush(o);
|
|
1203
1280
|
}
|
|
1204
1281
|
|
|
@@ -1259,6 +1336,14 @@ function spawnWebIdeMessageWorker(cfg, msg) {
|
|
|
1259
1336
|
try {
|
|
1260
1337
|
const { createApmApiClient: createApmApiClient2 } = await Promise.resolve().then(() => (init_client(), client_exports));
|
|
1261
1338
|
const api = createApmApiClient2(cfg);
|
|
1339
|
+
if (msg.type === "webide-package") {
|
|
1340
|
+
await api.cli.projectPackageUpdateStatus({
|
|
1341
|
+
id: msg.packageId,
|
|
1342
|
+
status: "CANCELLED",
|
|
1343
|
+
error: reason
|
|
1344
|
+
});
|
|
1345
|
+
return;
|
|
1346
|
+
}
|
|
1262
1347
|
await api.cli.webideSetMessageError({
|
|
1263
1348
|
id: msg.messageId,
|
|
1264
1349
|
error: reason,
|
|
@@ -1496,6 +1581,48 @@ function handleStopTerminalsAction(payload, ctx) {
|
|
|
1496
1581
|
trackActionTask(ctx, task);
|
|
1497
1582
|
}
|
|
1498
1583
|
|
|
1584
|
+
// src/commands/connect/actions/package.ts
|
|
1585
|
+
init_client();
|
|
1586
|
+
function handleWebIdePackageAction(payload, ctx) {
|
|
1587
|
+
const perMessageController = new AbortController();
|
|
1588
|
+
ctx.activeRuns.set(payload.messageId, perMessageController);
|
|
1589
|
+
if (ctx.pendingCancels.has(payload.messageId)) {
|
|
1590
|
+
ctx.activeRuns.delete(payload.messageId);
|
|
1591
|
+
ctx.pendingCancels.delete(payload.messageId);
|
|
1592
|
+
const cancelTask = (async () => {
|
|
1593
|
+
try {
|
|
1594
|
+
const api = createApmApiClient(ctx.cfg);
|
|
1595
|
+
await api.cli.projectPackageUpdateStatus({
|
|
1596
|
+
id: payload.packageId,
|
|
1597
|
+
status: "CANCELLED",
|
|
1598
|
+
error: "\u5DF2\u53D6\u6D88"
|
|
1599
|
+
});
|
|
1600
|
+
} catch (err) {
|
|
1601
|
+
console.error(
|
|
1602
|
+
`[apm] webide-package \u9884\u53D6\u6D88\u5199\u7EC8\u6001\u5931\u8D25 packageId=${payload.packageId}:`,
|
|
1603
|
+
err instanceof Error ? err.message : err
|
|
1604
|
+
);
|
|
1605
|
+
}
|
|
1606
|
+
})();
|
|
1607
|
+
trackActionTask(ctx, cancelTask);
|
|
1608
|
+
return;
|
|
1609
|
+
}
|
|
1610
|
+
const task = (async () => {
|
|
1611
|
+
const handle = spawnWebIdeMessageWorker(ctx.cfg, payload);
|
|
1612
|
+
const onAbort = () => handle.cancel(payload.messageId);
|
|
1613
|
+
perMessageController.signal.addEventListener("abort", onAbort, {
|
|
1614
|
+
once: true
|
|
1615
|
+
});
|
|
1616
|
+
try {
|
|
1617
|
+
await handle.done;
|
|
1618
|
+
} finally {
|
|
1619
|
+
perMessageController.signal.removeEventListener("abort", onAbort);
|
|
1620
|
+
ctx.activeRuns.delete(payload.messageId);
|
|
1621
|
+
}
|
|
1622
|
+
})();
|
|
1623
|
+
trackActionTask(ctx, task);
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1499
1626
|
// src/commands/connect/actions/index.ts
|
|
1500
1627
|
function dispatchConnectAction(payload, ctx) {
|
|
1501
1628
|
switch (payload.type) {
|
|
@@ -1513,6 +1640,9 @@ function dispatchConnectAction(payload, ctx) {
|
|
|
1513
1640
|
case "webide-stop-terminals":
|
|
1514
1641
|
handleStopTerminalsAction(payload, ctx);
|
|
1515
1642
|
return;
|
|
1643
|
+
case "webide-package":
|
|
1644
|
+
handleWebIdePackageAction(payload, ctx);
|
|
1645
|
+
return;
|
|
1516
1646
|
}
|
|
1517
1647
|
}
|
|
1518
1648
|
|
|
@@ -1858,7 +1988,7 @@ function buildProgram() {
|
|
|
1858
1988
|
).version(readCliVersion(), "-V, --version", "\u663E\u793A\u7248\u672C\u53F7").helpOption("-h, --help", "\u663E\u793A\u5E2E\u52A9").showHelpAfterError(true);
|
|
1859
1989
|
program.command("login").description(
|
|
1860
1990
|
"\u9A8C\u8BC1 API Key \u5E76\u5199\u5165 ~/.config/apm/config.json\uFF08GET /api/v1/cli/me\uFF09"
|
|
1861
|
-
).option("--api-key <key>", "\
|
|
1991
|
+
).option("--api-key <key>", "\u8FDC\u7A0B\u4E3B\u673A API Key\uFF08cm_ \u5F00\u5934\uFF09").option("--server <url>", "API \u6839\u5730\u5740\uFF0C\u4F8B\u5982 http://127.0.0.1:3000").action(async (opts) => {
|
|
1862
1992
|
await runLogin(opts);
|
|
1863
1993
|
});
|
|
1864
1994
|
program.command("init").description("\u5728\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u6309 WebIDE \u5DE5\u4F5C\u533A\u521D\u59CB\u5316\uFF1A\u5199\u5165\u6307\u5357\u4E0E webide \u89C4\u5219").action(async () => {
|