ai-project-manage-cli 6.0.60 → 6.0.62

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.
Files changed (2) hide show
  1. package/dist/index.js +66 -17
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -477,6 +477,10 @@ var requestConfig = {
477
477
  method: "PUT",
478
478
  path: "/cli/coordinator-deployments/status"
479
479
  }),
480
+ syncCoordinatorDeploymentLog: defineEndpoint({
481
+ method: "PUT",
482
+ path: "/cli/coordinator-deployments/log"
483
+ }),
480
484
  completeCoordinatorDeployment: defineEndpoint({
481
485
  method: "PUT",
482
486
  path: "/cli/coordinator-deployments/complete"
@@ -2173,6 +2177,7 @@ function validateAgentWsMessage(value, kind) {
2173
2177
  import { spawn } from "node:child_process";
2174
2178
  import { readFileSync as readFileSync9 } from "node:fs";
2175
2179
  import { join as join13 } from "node:path";
2180
+ var DEPLOY_LOG_SYNC_INTERVAL_MS = 3e4;
2176
2181
  function readDeployConfig(workdir) {
2177
2182
  const configPath = join13(workspaceApmDir(workdir), "apm.config.json");
2178
2183
  try {
@@ -2193,7 +2198,10 @@ function resolveDeployCommand(workdir, environment) {
2193
2198
  function missingDeployCommandMessage(environment) {
2194
2199
  return `deploy.${environment} \u90E8\u7F72\u547D\u4EE4\u672A\u914D\u7F6E\uFF0C\u8BF7\u5148\u914D\u7F6E`;
2195
2200
  }
2196
- function runShellCommand(command, cwd, signal) {
2201
+ function buildDeployLog(stdout, stderr) {
2202
+ return [stdout, stderr].filter(Boolean).join("\n");
2203
+ }
2204
+ function runShellCommand(command, cwd, signal, onOutput) {
2197
2205
  return new Promise((resolve5, reject) => {
2198
2206
  const child = spawn(command, {
2199
2207
  cwd,
@@ -2203,6 +2211,9 @@ function runShellCommand(command, cwd, signal) {
2203
2211
  });
2204
2212
  let stdout = "";
2205
2213
  let stderr = "";
2214
+ const emitLog = () => {
2215
+ onOutput?.(buildDeployLog(stdout, stderr));
2216
+ };
2206
2217
  const onAbort = () => {
2207
2218
  child.kill("SIGTERM");
2208
2219
  };
@@ -2213,9 +2224,11 @@ function runShellCommand(command, cwd, signal) {
2213
2224
  }
2214
2225
  child.stdout.on("data", (chunk) => {
2215
2226
  stdout += String(chunk);
2227
+ emitLog();
2216
2228
  });
2217
2229
  child.stderr.on("data", (chunk) => {
2218
2230
  stderr += String(chunk);
2231
+ emitLog();
2219
2232
  });
2220
2233
  child.on("error", (error) => {
2221
2234
  signal.removeEventListener("abort", onAbort);
@@ -2223,7 +2236,7 @@ function runShellCommand(command, cwd, signal) {
2223
2236
  });
2224
2237
  child.on("close", (code) => {
2225
2238
  signal.removeEventListener("abort", onAbort);
2226
- const log = [stdout, stderr].filter(Boolean).join("\n");
2239
+ const log = buildDeployLog(stdout, stderr);
2227
2240
  if (code === 0) {
2228
2241
  resolve5({ log });
2229
2242
  return;
@@ -2236,6 +2249,40 @@ function runShellCommand(command, cwd, signal) {
2236
2249
  });
2237
2250
  });
2238
2251
  }
2252
+ function createDeployLogSyncer(api, deploymentRunId) {
2253
+ let lastSyncedLog = "";
2254
+ let latestLog = "";
2255
+ const syncIfChanged = async () => {
2256
+ if (!latestLog || latestLog === lastSyncedLog) {
2257
+ return;
2258
+ }
2259
+ await api.cli.syncCoordinatorDeploymentLog({
2260
+ id: deploymentRunId,
2261
+ log: latestLog
2262
+ });
2263
+ lastSyncedLog = latestLog;
2264
+ };
2265
+ const timer = setInterval(() => {
2266
+ void syncIfChanged().catch((error) => {
2267
+ console.error(
2268
+ "[apm] deploy log sync failed:",
2269
+ error instanceof Error ? error.message : String(error)
2270
+ );
2271
+ });
2272
+ }, DEPLOY_LOG_SYNC_INTERVAL_MS);
2273
+ return {
2274
+ updateLog(log) {
2275
+ latestLog = log;
2276
+ },
2277
+ async flush() {
2278
+ clearInterval(timer);
2279
+ await syncIfChanged();
2280
+ },
2281
+ dispose() {
2282
+ clearInterval(timer);
2283
+ }
2284
+ };
2285
+ }
2239
2286
  async function handleInboundDeploy(cfg, msg, signal) {
2240
2287
  const api = createApmApiClient(cfg);
2241
2288
  const deploymentRunId = msg.deploymentRunId;
@@ -2261,8 +2308,16 @@ async function handleInboundDeploy(cfg, msg, signal) {
2261
2308
  `[apm] deploy start id=${deploymentRunId} env=${msg.environment} cwd=${workdir}`
2262
2309
  );
2263
2310
  console.log(`[apm] deploy command: ${command}`);
2311
+ const logSyncer = createDeployLogSyncer(api, deploymentRunId);
2312
+ let latestLog = "";
2264
2313
  try {
2265
- const { log } = await runShellCommand(command, workdir, signal);
2314
+ const { log } = await runShellCommand(command, workdir, signal, (log2) => {
2315
+ latestLog = log2;
2316
+ logSyncer.updateLog(log2);
2317
+ });
2318
+ latestLog = log;
2319
+ logSyncer.updateLog(log);
2320
+ await logSyncer.flush();
2266
2321
  await api.cli.completeCoordinatorDeployment({
2267
2322
  id: deploymentRunId,
2268
2323
  status: "SUCCESS",
@@ -2271,7 +2326,9 @@ async function handleInboundDeploy(cfg, msg, signal) {
2271
2326
  console.log(`[apm] deploy success id=${deploymentRunId}`);
2272
2327
  } catch (error) {
2273
2328
  const detail = error instanceof Error ? error.message : String(error);
2274
- const log = error && typeof error === "object" && "log" in error ? String(error.log ?? "") : "";
2329
+ const log = error && typeof error === "object" && "log" in error ? String(error.log ?? latestLog) : latestLog;
2330
+ logSyncer.updateLog(log);
2331
+ await logSyncer.flush();
2275
2332
  await api.cli.completeCoordinatorDeployment({
2276
2333
  id: deploymentRunId,
2277
2334
  status: "FAILED",
@@ -2279,6 +2336,8 @@ async function handleInboundDeploy(cfg, msg, signal) {
2279
2336
  error: detail
2280
2337
  });
2281
2338
  console.error(`[apm] deploy failed id=${deploymentRunId}: ${detail}`);
2339
+ } finally {
2340
+ logSyncer.dispose();
2282
2341
  }
2283
2342
  }
2284
2343
 
@@ -2675,16 +2734,6 @@ function createAppendMessageCustomTools(cfg, messageId) {
2675
2734
  };
2676
2735
  }
2677
2736
 
2678
- // src/commands/connect/playwright-mcp.ts
2679
- function createPlaywrightMcpServers() {
2680
- return {
2681
- playwright: {
2682
- command: "npx",
2683
- args: ["@playwright/mcp@latest", "--browser", "chrome", "--vision"]
2684
- }
2685
- };
2686
- }
2687
-
2688
2737
  // src/commands/connect/cursor-agent.ts
2689
2738
  setMaxListeners2(50);
2690
2739
  installAbortSignalDebug();
@@ -2712,8 +2761,8 @@ async function obtainAgent(ctx) {
2712
2761
  model: { id: ctx.model || "default" },
2713
2762
  local: {
2714
2763
  cwd: ctx.cwd
2715
- },
2716
- mcpServers: createPlaywrightMcpServers()
2764
+ }
2765
+ // mcpServers: createPlaywrightMcpServers(),
2717
2766
  };
2718
2767
  const savedAgentId = ctx.user ? loadSessionAgentId(ctx.workdir, ctx.sessionId, ctx.user) : void 0;
2719
2768
  if (savedAgentId) {
@@ -2781,7 +2830,7 @@ async function runCursorAgent(cfg, ctx, options) {
2781
2830
  logAbortSignalStats(signal, "runCursorAgent:after-addListener");
2782
2831
  try {
2783
2832
  const run = await agent.send(prompt, {
2784
- mcpServers: createPlaywrightMcpServers(),
2833
+ // mcpServers: createPlaywrightMcpServers(),
2785
2834
  local: {
2786
2835
  customTools: createAppendMessageCustomTools(cfg, ctx.messageId)
2787
2836
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-project-manage-cli",
3
- "version": "6.0.60",
3
+ "version": "6.0.62",
4
4
  "description": "命令行工具:后续用于调用平台后端 API 完成运维与自动化操作",
5
5
  "type": "module",
6
6
  "private": false,