ai-project-manage-cli 8.1.1 → 8.1.3

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 CHANGED
@@ -1044,6 +1044,7 @@ function validateWebIdeMessagePush(o) {
1044
1044
  return { ok: false, reason: "webide-message \u7F3A\u5C11 user" };
1045
1045
  }
1046
1046
  const useNewAgent = o.useNewAgent === true;
1047
+ const tools = Array.isArray(o.tools) ? o.tools.filter((t) => typeof t === "string" && t.trim().length > 0).map((t) => t.trim()) : [];
1047
1048
  return {
1048
1049
  ok: true,
1049
1050
  data: {
@@ -1056,7 +1057,8 @@ function validateWebIdeMessagePush(o) {
1056
1057
  apiKey: o.apiKey.trim(),
1057
1058
  workdir: o.workdir.trim(),
1058
1059
  user: o.user.trim(),
1059
- ...useNewAgent ? { useNewAgent: true } : {}
1060
+ ...useNewAgent ? { useNewAgent: true } : {},
1061
+ tools
1060
1062
  }
1061
1063
  };
1062
1064
  }
@@ -2250,12 +2250,22 @@ AskQuestion \u5DF2\u901A\u8FC7 MCP \u670D\u52A1\u5668 custom-user-tools \u6CE8\u
2250
2250
  var WORKSPACE_BOUNDARY_HINT = `[\u5DE5\u4F5C\u533A\u8FB9\u754C]
2251
2251
  \u6240\u6709\u6587\u4EF6\u8BFB\u5199\u3001\u641C\u7D22\uFF08Grep/Glob/Read\uFF09\u3001Shell \u5FC5\u987B\u4E25\u683C\u9650\u5236\u5728\u5F53\u524D\u5DE5\u4F5C\u533A cwd \u5185\u3002
2252
2252
  \u7981\u6B62\u8BBF\u95EE\u5DE5\u4F5C\u533A\u5916\u8DEF\u5F84\uFF08\u5982\u5176\u5B83\u9879\u76EE\u3001~/.cursor\u3001agent-transcripts\u3001\u7CFB\u7EDF\u76EE\u5F55\u7B49\uFF09\u3002`;
2253
+ function wantsTool(name, options, legacyDefault) {
2254
+ if (options.toolNames !== void 0) {
2255
+ return options.toolNames.includes(name);
2256
+ }
2257
+ return legacyDefault;
2258
+ }
2253
2259
  function createCursorCustomTools(cfg2, options) {
2260
+ const enableAppend = options.enableAppendMessage !== false && Boolean(options.appendMessageContent);
2261
+ const enableAsk = options.enableAskQuestion !== false;
2262
+ const enablePlan = options.enableWebIdePlanTools === true;
2263
+ const enableMysql = options.enableMysqlTools === true;
2254
2264
  const tools = {
2255
- ...options.enableAppendMessage !== false && options.appendMessageContent ? createAppendMessageCustomTools({
2265
+ ...wantsTool("AppendMessage", options, enableAppend) && options.appendMessageContent ? createAppendMessageCustomTools({
2256
2266
  appendContent: options.appendMessageContent
2257
2267
  }) : {},
2258
- ...options.enableAskQuestion !== false ? createAskQuestionTool({
2268
+ ...wantsTool("AskQuestion", options, enableAsk) ? createAskQuestionTool({
2259
2269
  onInvoke: options?.onAskQuestion,
2260
2270
  execute: options?.askQuestionExecute
2261
2271
  }) : {}
@@ -2263,24 +2273,39 @@ function createCursorCustomTools(cfg2, options) {
2263
2273
  if (options?.taskId && options.workdir) {
2264
2274
  const { cli } = createApmApiClient(cfg2);
2265
2275
  const taskId = options.taskId;
2266
- if (options.enableWebIdePlanTools) {
2276
+ if (wantsTool("RecommendPlan", options, enablePlan)) {
2267
2277
  Object.assign(
2268
2278
  tools,
2269
2279
  createRecommendPlanTool({
2270
2280
  webideRecommendPlan: (args) => cli.webideRecommendPlan({ taskId, ...args })
2271
- }),
2281
+ })
2282
+ );
2283
+ }
2284
+ if (wantsTool("UpsertWebIdePlan", options, enablePlan)) {
2285
+ Object.assign(
2286
+ tools,
2272
2287
  createUpsertWebIdePlanTool({
2273
2288
  webideUpsertPlan: (args) => cli.webideUpsertPlan({ taskId, ...args })
2274
- }),
2289
+ })
2290
+ );
2291
+ }
2292
+ if (wantsTool("UpsertWebIdeTestCases", options, enablePlan)) {
2293
+ Object.assign(
2294
+ tools,
2275
2295
  createUpsertWebIdeTestCasesTool({
2276
2296
  webideReplaceTestCases: (args) => cli.webideReplaceTestCases({ taskId, ...args })
2277
- }),
2297
+ })
2298
+ );
2299
+ }
2300
+ if (wantsTool("MergeWebIdePullRequests", options, enablePlan)) {
2301
+ Object.assign(
2302
+ tools,
2278
2303
  createMergeWebIdePullRequestsTool({
2279
2304
  webideMergePullRequests: () => cli.webideMergePullRequests({ taskId })
2280
2305
  })
2281
2306
  );
2282
2307
  }
2283
- if (options.enableMysqlTools && options.sqlExecutionId && options.workdir) {
2308
+ if (wantsTool("MysqlExecute", options, enableMysql) && options.sqlExecutionId && options.workdir) {
2284
2309
  Object.assign(
2285
2310
  tools,
2286
2311
  createMysqlExecuteTool({
@@ -2440,6 +2465,7 @@ async function runCursorAgent(cfg2, ctx, options) {
2440
2465
  enableWebIdePlanTools: options.enableWebIdePlanTools,
2441
2466
  enableMysqlTools: options.enableMysqlTools,
2442
2467
  sqlExecutionId: options.sqlExecutionId,
2468
+ toolNames: options.toolNames,
2443
2469
  taskId: options.taskId,
2444
2470
  workdir,
2445
2471
  enablePackageStatusTools: options.enablePackageStatusTools,
@@ -4366,9 +4392,6 @@ function isStartLocalServicesAction(_action) {
4366
4392
  function isDesignAction(action) {
4367
4393
  return action === "request-design" || action === "request-revise-design";
4368
4394
  }
4369
- function isExecuteSqlAction(action) {
4370
- return action === "request-execute-sql";
4371
- }
4372
4395
  function syncLocalTaskStatus(workdir, taskId, msg2, status) {
4373
4396
  syncWebIdeTaskState(workdir, taskId, {
4374
4397
  messageId: msg2.messageId,
@@ -4612,8 +4635,8 @@ async function handleWebIdeInboundMessage(cfg2, msg2, signal) {
4612
4635
  await syncPrepLog();
4613
4636
  const startLocalServices = isStartLocalServicesAction(msg2.action);
4614
4637
  const designAction = isDesignAction(msg2.action);
4615
- const executeSql = isExecuteSqlAction(msg2.action);
4616
4638
  const useNewAgent = msg2.useNewAgent === true;
4639
+ const toolNames = Array.isArray(msg2.tools) ? msg2.tools.map((t) => String(t).trim()).filter(Boolean) : [];
4617
4640
  if (useNewAgent && !startLocalServices) {
4618
4641
  if (designAction) {
4619
4642
  clearWebIdeDesignAgentId(workdir, taskId);
@@ -4622,8 +4645,8 @@ async function handleWebIdeInboundMessage(cfg2, msg2, signal) {
4622
4645
  }
4623
4646
  }
4624
4647
  const savedAgentId = startLocalServices || useNewAgent ? void 0 : designAction ? loadWebIdeDesignAgentId(workdir, taskId) : loadWebIdeAgentId(workdir, taskId);
4625
- const promptPayload = executeSql ? parseWebIdePromptPayload(msg2.content) : null;
4626
- const sqlExecutionId = executeSql && typeof promptPayload?.executionId === "string" ? promptPayload.executionId.trim() : void 0;
4648
+ const promptPayload = toolNames.includes("MysqlExecute") ? parseWebIdePromptPayload(msg2.content) : null;
4649
+ const sqlExecutionId = toolNames.includes("MysqlExecute") && typeof promptPayload?.executionId === "string" ? promptPayload.executionId.trim() : void 0;
4627
4650
  const persistAgentId = (agentId) => {
4628
4651
  if (startLocalServices) return;
4629
4652
  if (designAction) {
@@ -4651,18 +4674,21 @@ ${assumptionAnswersText}` : msg2.content,
4651
4674
  forceSend: true,
4652
4675
  eventSession,
4653
4676
  appendMessageContent: (content) => appendContent(cfg2, messageId, content),
4654
- askQuestionExecute: startLocalServices ? void 0 : createWebIdeAskQuestionExecute({
4677
+ askQuestionExecute: !startLocalServices && toolNames.includes("AskQuestion") ? createWebIdeAskQuestionExecute({
4655
4678
  cfg: cfg2,
4656
4679
  taskId,
4657
4680
  onAwaitingAssumptions: () => {
4658
4681
  pausedForAssumptions = true;
4659
4682
  }
4660
- }),
4661
- enableAskQuestion: !startLocalServices && !executeSql,
4662
- enableWebIdePlanTools: !startLocalServices && !executeSql && !designAction,
4683
+ }) : void 0,
4684
+ // 工具名单完全以服务端模板配置为准,不再按 action 硬编码开关
4685
+ enableAppendMessage: false,
4686
+ enableAskQuestion: false,
4687
+ enableWebIdePlanTools: false,
4688
+ enableMysqlTools: false,
4663
4689
  enablePtySessionMcp: startLocalServices,
4664
- enableMysqlTools: executeSql,
4665
4690
  sqlExecutionId,
4691
+ toolNames,
4666
4692
  enableSandbox: false,
4667
4693
  onInvalidatePersistedAgentId: startLocalServices ? void 0 : () => {
4668
4694
  if (designAction) {
@@ -4721,7 +4747,7 @@ ${assumptionAnswersText}` : msg2.content,
4721
4747
  detail,
4722
4748
  tokenUsage
4723
4749
  );
4724
- if (executeSql && sqlExecutionId) {
4750
+ if (sqlExecutionId) {
4725
4751
  try {
4726
4752
  await api.cli.webideFinalizeSqlExecution({
4727
4753
  executionId: sqlExecutionId,
@@ -4746,7 +4772,7 @@ ${assumptionAnswersText}` : msg2.content,
4746
4772
  "\u5DF2\u53D6\u6D88",
4747
4773
  tokenUsage
4748
4774
  );
4749
- if (executeSql && sqlExecutionId) {
4775
+ if (sqlExecutionId) {
4750
4776
  try {
4751
4777
  await api.cli.webideFinalizeSqlExecution({
4752
4778
  executionId: sqlExecutionId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-project-manage-cli",
3
- "version": "8.1.1",
3
+ "version": "8.1.3",
4
4
  "description": "命令行工具:后续用于调用平台后端 API 完成运维与自动化操作",
5
5
  "type": "module",
6
6
  "private": false,