ai-project-manage-cli 8.1.12 → 8.1.13

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/worker-script.js +191 -82
  2. package/package.json +1 -1
@@ -2468,10 +2468,76 @@ function createPtySessionMcpServers(cfg2) {
2468
2468
  }
2469
2469
 
2470
2470
  // src/commands/connect/remote-local-agent-store.ts
2471
+ import { createHash as createHash2 } from "node:crypto";
2472
+ import {
2473
+ existsSync as existsSync5,
2474
+ mkdirSync as mkdirSync4,
2475
+ readFileSync as readFileSync4,
2476
+ rmSync,
2477
+ unlinkSync,
2478
+ writeFileSync as writeFileSync3
2479
+ } from "node:fs";
2480
+ import { dirname as dirname2, join as join4 } from "node:path";
2471
2481
  var INLINE_CHECKPOINT_MAX_BYTES = 256 * 1024;
2482
+ var CHECKPOINT_CACHE_DIR = join4(APM_CONFIG_DIR, "cursor-checkpoint-cache");
2472
2483
  function checkpointObjectKey(agentId, blobId) {
2473
2484
  return `cursor-agents/${agentId}/checkpoints/${blobId}`;
2474
2485
  }
2486
+ function safeBlobFileName(blobId) {
2487
+ if (/^[a-zA-Z0-9._-]+$/.test(blobId)) return blobId;
2488
+ return createHash2("sha256").update(blobId).digest("hex");
2489
+ }
2490
+ function checkpointCachePath(agentId, blobId) {
2491
+ return join4(CHECKPOINT_CACHE_DIR, agentId, safeBlobFileName(blobId));
2492
+ }
2493
+ function checkpointCacheKey(agentId, blobId) {
2494
+ return `${agentId}\0${blobId}`;
2495
+ }
2496
+ function readLocalCheckpoint(agentId, blobId) {
2497
+ try {
2498
+ const path3 = checkpointCachePath(agentId, blobId);
2499
+ if (!existsSync5(path3)) return null;
2500
+ return new Uint8Array(readFileSync4(path3));
2501
+ } catch {
2502
+ return null;
2503
+ }
2504
+ }
2505
+ function writeLocalCheckpoint(agentId, blobId, data) {
2506
+ try {
2507
+ const path3 = checkpointCachePath(agentId, blobId);
2508
+ mkdirSync4(dirname2(path3), { recursive: true });
2509
+ writeFileSync3(path3, Buffer.from(data));
2510
+ } catch (err) {
2511
+ console.warn(
2512
+ `[apm] checkpoint \u672C\u5730\u7F13\u5B58\u5199\u5165\u5931\u8D25 agentId=${agentId} blobId=${blobId}:`,
2513
+ err instanceof Error ? err.message : err
2514
+ );
2515
+ }
2516
+ }
2517
+ function deleteLocalCheckpoint(agentId, blobId) {
2518
+ try {
2519
+ const path3 = checkpointCachePath(agentId, blobId);
2520
+ if (existsSync5(path3)) unlinkSync(path3);
2521
+ } catch {
2522
+ }
2523
+ }
2524
+ function clearLocalCheckpointCache(agentId) {
2525
+ try {
2526
+ if (agentId?.trim()) {
2527
+ const dir = join4(CHECKPOINT_CACHE_DIR, agentId.trim());
2528
+ if (existsSync5(dir)) rmSync(dir, { recursive: true, force: true });
2529
+ return;
2530
+ }
2531
+ if (existsSync5(CHECKPOINT_CACHE_DIR)) {
2532
+ rmSync(CHECKPOINT_CACHE_DIR, { recursive: true, force: true });
2533
+ }
2534
+ } catch (err) {
2535
+ console.warn(
2536
+ `[apm] \u6E05\u7406 checkpoint \u672C\u5730\u7F13\u5B58\u5931\u8D25:`,
2537
+ err instanceof Error ? err.message : err
2538
+ );
2539
+ }
2540
+ }
2475
2541
  function asCheckpointRef(value) {
2476
2542
  if (value === void 0) return void 0;
2477
2543
  if (value === null) return null;
@@ -2547,6 +2613,7 @@ function base64ToBytes(dataBase64) {
2547
2613
  function createRemoteLocalAgentStore(cfg2) {
2548
2614
  const api = createApmApiClient(cfg2);
2549
2615
  let minioCache = null;
2616
+ const memoryCheckpointCache = /* @__PURE__ */ new Map();
2550
2617
  function getMinio() {
2551
2618
  if (!minioCache) {
2552
2619
  minioCache = createApmLogMinioClient(cfg2).then(({ client, bucket }) => ({
@@ -2556,6 +2623,14 @@ function createRemoteLocalAgentStore(cfg2) {
2556
2623
  }
2557
2624
  return minioCache;
2558
2625
  }
2626
+ function rememberCheckpoint(agentId, blobId, data) {
2627
+ memoryCheckpointCache.set(checkpointCacheKey(agentId, blobId), data);
2628
+ writeLocalCheckpoint(agentId, blobId, data);
2629
+ }
2630
+ function forgetCheckpoint(agentId, blobId) {
2631
+ memoryCheckpointCache.delete(checkpointCacheKey(agentId, blobId));
2632
+ deleteLocalCheckpoint(agentId, blobId);
2633
+ }
2559
2634
  async function upsertAgent(agent) {
2560
2635
  const row = await api.cli.cursorStoreUpsertAgent({
2561
2636
  agentId: agent.agentId,
@@ -2606,6 +2681,7 @@ function createRemoteLocalAgentStore(cfg2) {
2606
2681
  byteSize: input.data.byteLength,
2607
2682
  createdAt
2608
2683
  });
2684
+ rememberCheckpoint(input.agentId, input.blobId, input.data);
2609
2685
  return;
2610
2686
  }
2611
2687
  await api.cli.cursorStorePutCheckpoint({
@@ -2615,21 +2691,34 @@ function createRemoteLocalAgentStore(cfg2) {
2615
2691
  byteSize: input.data.byteLength,
2616
2692
  createdAt
2617
2693
  });
2694
+ rememberCheckpoint(input.agentId, input.blobId, input.data);
2618
2695
  }
2619
2696
  async function readCheckpointBytes(input) {
2697
+ const memKey = checkpointCacheKey(input.agentId, input.blobId);
2698
+ const cached = memoryCheckpointCache.get(memKey);
2699
+ if (cached) return cached;
2700
+ const local = readLocalCheckpoint(input.agentId, input.blobId);
2701
+ if (local) {
2702
+ memoryCheckpointCache.set(memKey, local);
2703
+ return local;
2704
+ }
2620
2705
  const row = await api.cli.cursorStoreGetCheckpoint({
2621
2706
  agentId: input.agentId,
2622
2707
  blobId: input.blobId
2623
2708
  });
2624
2709
  if (!row) return null;
2710
+ let bytes = null;
2625
2711
  if (row.dataBase64) {
2626
- return base64ToBytes(row.dataBase64);
2712
+ bytes = base64ToBytes(row.dataBase64);
2713
+ } else {
2714
+ const objectKey = row.objectKey?.trim();
2715
+ if (!objectKey) return null;
2716
+ const { client, bucket } = await getMinio();
2717
+ const buf = await client.getObjectBuffer(bucket, objectKey);
2718
+ bytes = new Uint8Array(buf);
2627
2719
  }
2628
- const objectKey = row.objectKey?.trim();
2629
- if (!objectKey) return null;
2630
- const { client, bucket } = await getMinio();
2631
- const buf = await client.getObjectBuffer(bucket, objectKey);
2632
- return new Uint8Array(buf);
2720
+ rememberCheckpoint(input.agentId, input.blobId, bytes);
2721
+ return bytes;
2633
2722
  }
2634
2723
  return {
2635
2724
  agents: {
@@ -2798,6 +2887,23 @@ function createRemoteLocalAgentStore(cfg2) {
2798
2887
  const blobIds = input.filter.blobIds?.map((id) => id.trim()).filter(Boolean);
2799
2888
  if (agentIds && agentIds.length > 0 || blobIds && blobIds.length > 0) {
2800
2889
  await api.cli.cursorStoreDeleteCheckpoints({ agentIds, blobIds });
2890
+ if (agentIds && agentIds.length > 0 && !blobIds?.length) {
2891
+ for (const id of agentIds) clearLocalCheckpointCache(id);
2892
+ } else if (agentIds && blobIds) {
2893
+ for (const id of agentIds) {
2894
+ for (const blobId of blobIds) forgetCheckpoint(id, blobId);
2895
+ }
2896
+ } else if (blobIds) {
2897
+ for (const blobId of blobIds) {
2898
+ for (const key of memoryCheckpointCache.keys()) {
2899
+ const sep2 = key.indexOf("\0");
2900
+ if (sep2 < 0) continue;
2901
+ if (key.slice(sep2 + 1) === blobId) {
2902
+ forgetCheckpoint(key.slice(0, sep2), blobId);
2903
+ }
2904
+ }
2905
+ }
2906
+ }
2801
2907
  return;
2802
2908
  }
2803
2909
  let cursor;
@@ -2814,6 +2920,8 @@ function createRemoteLocalAgentStore(cfg2) {
2814
2920
  if (!page.nextCursor) break;
2815
2921
  cursor = page.nextCursor;
2816
2922
  }
2923
+ clearLocalCheckpointCache();
2924
+ memoryCheckpointCache.clear();
2817
2925
  },
2818
2926
  async list(input) {
2819
2927
  const page = await api.cli.cursorStoreListCheckpoints({
@@ -3228,14 +3336,14 @@ function createThrottledWebIdeMessageLogSync(cfg2, ctx, onError, options) {
3228
3336
 
3229
3337
  // src/commands/sync-webide-agent.ts
3230
3338
  import {
3231
- existsSync as existsSync5,
3232
- mkdirSync as mkdirSync4,
3339
+ existsSync as existsSync6,
3340
+ mkdirSync as mkdirSync5,
3233
3341
  readdirSync as readdirSync3,
3234
- readFileSync as readFileSync4,
3235
- unlinkSync,
3236
- writeFileSync as writeFileSync3
3342
+ readFileSync as readFileSync5,
3343
+ unlinkSync as unlinkSync2,
3344
+ writeFileSync as writeFileSync4
3237
3345
  } from "fs";
3238
- import { join as join4 } from "path";
3346
+ import { join as join5 } from "path";
3239
3347
  var REVISION_FILE = ".webide-agent.json";
3240
3348
  var RULE_KEY = /^[a-z0-9_]+$/;
3241
3349
  function withTrailingNewline(text) {
@@ -3243,10 +3351,10 @@ function withTrailingNewline(text) {
3243
3351
  `;
3244
3352
  }
3245
3353
  function readRevision(apmDir) {
3246
- const path3 = toFsPath(join4(apmDir, REVISION_FILE));
3247
- if (!existsSync5(path3)) return null;
3354
+ const path3 = toFsPath(join5(apmDir, REVISION_FILE));
3355
+ if (!existsSync6(path3)) return null;
3248
3356
  try {
3249
- const parsed = JSON.parse(readFileSync4(path3, "utf8"));
3357
+ const parsed = JSON.parse(readFileSync5(path3, "utf8"));
3250
3358
  if (parsed?.version === 1 && parsed.revision?.trim()) {
3251
3359
  return parsed.revision.trim();
3252
3360
  }
@@ -3256,8 +3364,8 @@ function readRevision(apmDir) {
3256
3364
  return null;
3257
3365
  }
3258
3366
  function writeRevision(apmDir, revision) {
3259
- writeFileSync3(
3260
- toFsPath(join4(apmDir, REVISION_FILE)),
3367
+ writeFileSync4(
3368
+ toFsPath(join5(apmDir, REVISION_FILE)),
3261
3369
  `${JSON.stringify({ version: 1, revision }, null, 2)}
3262
3370
  `,
3263
3371
  "utf8"
@@ -3271,14 +3379,14 @@ async function syncWebIdeAgentFiles(workdir, cfg2) {
3271
3379
  throw new Error("[apm] \u5E73\u53F0\u672A\u8FD4\u56DE WebIDE \u89C4\u5219\u7248\u672C");
3272
3380
  }
3273
3381
  const apmDir = workspaceApmDir(workdir);
3274
- mkdirSync4(toFsPath(apmDir), { recursive: true });
3382
+ mkdirSync5(toFsPath(apmDir), { recursive: true });
3275
3383
  if (readRevision(apmDir) === revision) {
3276
3384
  return { revision, wrote: false, ruleCount: bundle.rules?.length ?? 0 };
3277
3385
  }
3278
- const rulesDir = join4(apmDir, "rules");
3279
- mkdirSync4(toFsPath(rulesDir), { recursive: true });
3280
- writeFileSync3(
3281
- toFsPath(join4(apmDir, "AGENTS.md")),
3386
+ const rulesDir = join5(apmDir, "rules");
3387
+ mkdirSync5(toFsPath(rulesDir), { recursive: true });
3388
+ writeFileSync4(
3389
+ toFsPath(join5(apmDir, "AGENTS.md")),
3282
3390
  withTrailingNewline(bundle.guide ?? ""),
3283
3391
  "utf8"
3284
3392
  );
@@ -3289,8 +3397,8 @@ async function syncWebIdeAgentFiles(workdir, cfg2) {
3289
3397
  throw new Error(`[apm] \u975E\u6CD5\u89C4\u5219\u540D: ${key || "(\u7A7A)"}`);
3290
3398
  }
3291
3399
  keep.add(`${key}.md`);
3292
- writeFileSync3(
3293
- toFsPath(join4(rulesDir, `${key}.md`)),
3400
+ writeFileSync4(
3401
+ toFsPath(join5(rulesDir, `${key}.md`)),
3294
3402
  withTrailingNewline(rule.body ?? ""),
3295
3403
  "utf8"
3296
3404
  );
@@ -3298,7 +3406,7 @@ async function syncWebIdeAgentFiles(workdir, cfg2) {
3298
3406
  for (const name of readdirSync3(toFsPath(rulesDir))) {
3299
3407
  if (!name.endsWith(".md")) continue;
3300
3408
  if (keep.has(name)) continue;
3301
- unlinkSync(toFsPath(join4(rulesDir, name)));
3409
+ unlinkSync2(toFsPath(join5(rulesDir, name)));
3302
3410
  }
3303
3411
  writeRevision(apmDir, revision);
3304
3412
  return {
@@ -3323,14 +3431,14 @@ async function ensureWorkspaceInitialized(workdir) {
3323
3431
 
3324
3432
  // src/utils/project-documents.ts
3325
3433
  import {
3326
- existsSync as existsSync6,
3434
+ existsSync as existsSync7,
3327
3435
  readdirSync as readdirSync4,
3328
- readFileSync as readFileSync5,
3329
- rmSync,
3330
- writeFileSync as writeFileSync4
3436
+ readFileSync as readFileSync6,
3437
+ rmSync as rmSync2,
3438
+ writeFileSync as writeFileSync5
3331
3439
  } from "fs";
3332
- import { createHash as createHash2 } from "crypto";
3333
- import { dirname as dirname2, join as join5, relative as relative4, sep } from "path";
3440
+ import { createHash as createHash3 } from "crypto";
3441
+ import { dirname as dirname3, join as join6, relative as relative4, sep } from "path";
3334
3442
  var MANIFEST_FILE = "manifest.json";
3335
3443
  function normalizeProjectIdForPath(projectId) {
3336
3444
  const id = projectId.trim();
@@ -3344,11 +3452,11 @@ function normalizeProjectIdForPath(projectId) {
3344
3452
  }
3345
3453
  function projectDocumentsDir(apmRoot, projectId) {
3346
3454
  const id = normalizeProjectIdForPath(projectId);
3347
- return join5(apmRoot ?? workspaceApmDir(), "project", id);
3455
+ return join6(apmRoot ?? workspaceApmDir(), "project", id);
3348
3456
  }
3349
3457
  function projectDocumentLocalPath(apmRoot, projectId, documentPath) {
3350
3458
  const normalized = normalizeLocalDocumentPath(documentPath);
3351
- return join5(
3459
+ return join6(
3352
3460
  projectDocumentsDir(apmRoot, projectId),
3353
3461
  ...normalized.split("/")
3354
3462
  );
@@ -3365,19 +3473,19 @@ function normalizeLocalDocumentPath(path3) {
3365
3473
  return segments.join("/");
3366
3474
  }
3367
3475
  function hashLocalFileContent(content) {
3368
- return createHash2("sha256").update(content, "utf8").digest("hex");
3476
+ return createHash3("sha256").update(content, "utf8").digest("hex");
3369
3477
  }
3370
3478
  function readLocalManifest(apmRoot, projectId) {
3371
- const manifestPath2 = join5(
3479
+ const manifestPath2 = join6(
3372
3480
  projectDocumentsDir(apmRoot, projectId),
3373
3481
  MANIFEST_FILE
3374
3482
  );
3375
- if (!existsSync6(manifestPath2)) {
3483
+ if (!existsSync7(manifestPath2)) {
3376
3484
  return null;
3377
3485
  }
3378
3486
  try {
3379
3487
  return JSON.parse(
3380
- readFileSync5(manifestPath2, "utf8")
3488
+ readFileSync6(manifestPath2, "utf8")
3381
3489
  );
3382
3490
  } catch {
3383
3491
  return null;
@@ -3385,13 +3493,13 @@ function readLocalManifest(apmRoot, projectId) {
3385
3493
  }
3386
3494
  function listLocalDocumentPaths(apmRoot, projectId) {
3387
3495
  const root = projectDocumentsDir(apmRoot, projectId);
3388
- if (!existsSync6(root)) {
3496
+ if (!existsSync7(root)) {
3389
3497
  return [];
3390
3498
  }
3391
3499
  const paths = [];
3392
3500
  const walk = (dir) => {
3393
3501
  for (const entry of readdirSync4(dir, { withFileTypes: true })) {
3394
- const abs = join5(dir, entry.name);
3502
+ const abs = join6(dir, entry.name);
3395
3503
  if (entry.isDirectory()) {
3396
3504
  walk(abs);
3397
3505
  continue;
@@ -3510,8 +3618,8 @@ ${diagnostic ?? ""}`);
3510
3618
  const absPath = toFsPath(
3511
3619
  projectDocumentLocalPath(targetApmDir, projectId, doc.path)
3512
3620
  );
3513
- await ensureDirExists(dirname2(absPath));
3514
- writeFileSync4(absPath, doc.content, "utf8");
3621
+ await ensureDirExists(dirname3(absPath));
3622
+ writeFileSync5(absPath, doc.content, "utf8");
3515
3623
  downloaded += 1;
3516
3624
  }
3517
3625
  }
@@ -3520,13 +3628,13 @@ ${diagnostic ?? ""}`);
3520
3628
  const absPath = toFsPath(
3521
3629
  projectDocumentLocalPath(targetApmDir, projectId, path3)
3522
3630
  );
3523
- if (existsSync6(absPath)) {
3524
- rmSync(absPath, { force: true });
3631
+ if (existsSync7(absPath)) {
3632
+ rmSync2(absPath, { force: true });
3525
3633
  deleted += 1;
3526
3634
  }
3527
3635
  }
3528
- writeFileSync4(
3529
- toFsPath(join5(docsDir, MANIFEST_FILE)),
3636
+ writeFileSync5(
3637
+ toFsPath(join6(docsDir, MANIFEST_FILE)),
3530
3638
  `${JSON.stringify(remoteManifest, null, 2)}
3531
3639
  `,
3532
3640
  "utf8"
@@ -3569,7 +3677,7 @@ async function syncProjectDocumentsPush(cfg2, workdirPath, apmRoot, options) {
3569
3677
  const absPath = toFsPath(
3570
3678
  projectDocumentLocalPath(targetApmDir, projectId, path3)
3571
3679
  );
3572
- const content = readFileSync5(absPath, "utf8");
3680
+ const content = readFileSync6(absPath, "utf8");
3573
3681
  const contentHash = hashLocalFileContent(content);
3574
3682
  if (remoteHashByPath.get(path3) === contentHash) {
3575
3683
  continue;
@@ -4054,18 +4162,18 @@ async function handleStartProject(cfg2, msg2, signal) {
4054
4162
  }
4055
4163
 
4056
4164
  // src/commands/connect/webide-agent-registry.ts
4057
- import { existsSync as existsSync7, mkdirSync as mkdirSync5, readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "node:fs";
4058
- import { dirname as dirname3, resolve as resolve6 } from "node:path";
4165
+ import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync7, writeFileSync as writeFileSync6 } from "node:fs";
4166
+ import { dirname as dirname4, resolve as resolve6 } from "node:path";
4059
4167
  function registryPath(workdir, taskId, fileName = "cursor-agent.json") {
4060
4168
  return resolve6(workdir, ".apm", "webide", taskId, fileName);
4061
4169
  }
4062
4170
  var DESIGN_AGENT_FILE = "design-agent.json";
4063
4171
  function readRegistry(path3) {
4064
- if (!existsSync7(path3)) {
4172
+ if (!existsSync8(path3)) {
4065
4173
  return {};
4066
4174
  }
4067
4175
  try {
4068
- const parsed = JSON.parse(readFileSync6(path3, "utf8"));
4176
+ const parsed = JSON.parse(readFileSync7(path3, "utf8"));
4069
4177
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
4070
4178
  const raw = parsed;
4071
4179
  const state = {};
@@ -4094,8 +4202,8 @@ function readRegistry(path3) {
4094
4202
  return {};
4095
4203
  }
4096
4204
  function writeRegistry(path3, registry) {
4097
- mkdirSync5(dirname3(path3), { recursive: true });
4098
- writeFileSync5(path3, `${JSON.stringify(registry, null, 2)}
4205
+ mkdirSync6(dirname4(path3), { recursive: true });
4206
+ writeFileSync6(path3, `${JSON.stringify(registry, null, 2)}
4099
4207
  `, "utf8");
4100
4208
  }
4101
4209
  function syncWebIdeTaskState(workdir, taskId, patch) {
@@ -4136,7 +4244,7 @@ function saveWebIdeAgentId(workdir, taskId, agentId) {
4136
4244
  }
4137
4245
  function clearWebIdeAgentId(workdir, taskId) {
4138
4246
  const path3 = registryPath(workdir, taskId);
4139
- if (!existsSync7(path3)) return;
4247
+ if (!existsSync8(path3)) return;
4140
4248
  syncWebIdeTaskState(workdir, taskId, { agentId: "" });
4141
4249
  }
4142
4250
  function loadWebIdeDesignAgentId(workdir, taskId) {
@@ -4156,7 +4264,7 @@ function saveWebIdeDesignAgentId(workdir, taskId, agentId) {
4156
4264
  }
4157
4265
  function clearWebIdeDesignAgentId(workdir, taskId) {
4158
4266
  const path3 = registryPath(workdir, taskId, DESIGN_AGENT_FILE);
4159
- if (!existsSync7(path3)) return;
4267
+ if (!existsSync8(path3)) return;
4160
4268
  const current = readRegistry(path3);
4161
4269
  const next = { ...current };
4162
4270
  delete next.agentId;
@@ -4168,7 +4276,7 @@ function clearWebIdeDesignAgentId(workdir, taskId) {
4168
4276
  }
4169
4277
 
4170
4278
  // src/commands/clean-webide-cache.ts
4171
- import { existsSync as existsSync8, rmSync as rmSync2 } from "node:fs";
4279
+ import { existsSync as existsSync9, rmSync as rmSync3 } from "node:fs";
4172
4280
  import { resolve as resolve7 } from "node:path";
4173
4281
  async function purgeCursorAgentStoreForAgent(cfg2, agentId) {
4174
4282
  const trimmedAgentId = agentId.trim();
@@ -4195,6 +4303,7 @@ async function purgeCursorAgentStoreForAgent(cfg2, agentId) {
4195
4303
  await store.runs.delete({ filter: { agentIds: [trimmedAgentId] } });
4196
4304
  await store.checkpoints.delete({ filter: { agentIds: [trimmedAgentId] } });
4197
4305
  await store.agents.delete({ filter: { agentIds: [trimmedAgentId] } });
4306
+ clearLocalCheckpointCache(trimmedAgentId);
4198
4307
  return true;
4199
4308
  }
4200
4309
  async function cleanWebIdeWorkspaceCache(taskId, workdir, cfg2) {
@@ -4224,8 +4333,8 @@ async function cleanWebIdeWorkspaceCache(taskId, workdir, cfg2) {
4224
4333
  );
4225
4334
  }
4226
4335
  const dir = resolve7(trimmedWorkdir, ".apm", "webide", trimmedTaskId);
4227
- if (existsSync8(dir)) {
4228
- rmSync2(dir, { recursive: true, force: true });
4336
+ if (existsSync9(dir)) {
4337
+ rmSync3(dir, { recursive: true, force: true });
4229
4338
  console.log(`[apm] \u5DF2\u6E05\u7406 WebIDE \u7F13\u5B58 ${dir}`);
4230
4339
  } else {
4231
4340
  console.log(`[apm] WebIDE \u7F13\u5B58\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7 ${dir}`);
@@ -4546,8 +4655,8 @@ async function ensureWebIdePullRequests(cfg2, taskId, workdir) {
4546
4655
  }
4547
4656
 
4548
4657
  // src/commands/sync-webide-attachments.ts
4549
- import { existsSync as existsSync9, readFileSync as readFileSync7, writeFileSync as writeFileSync6 } from "fs";
4550
- import { join as join6 } from "path";
4658
+ import { existsSync as existsSync10, readFileSync as readFileSync8, writeFileSync as writeFileSync7 } from "fs";
4659
+ import { join as join7 } from "path";
4551
4660
  var MANIFEST_FILE2 = ".sync-manifest.json";
4552
4661
  async function downloadAttachment(cfg2, attachmentId) {
4553
4662
  const base = cfg2.baseUrl.trim().replace(/\/+$/, "");
@@ -4563,13 +4672,13 @@ async function downloadAttachment(cfg2, attachmentId) {
4563
4672
  return Buffer.from(await res.arrayBuffer());
4564
4673
  }
4565
4674
  function loadManifest(dir) {
4566
- const path3 = join6(dir, MANIFEST_FILE2);
4567
- if (!existsSync9(path3)) {
4675
+ const path3 = join7(dir, MANIFEST_FILE2);
4676
+ if (!existsSync10(path3)) {
4568
4677
  return { version: 1, attachments: {} };
4569
4678
  }
4570
4679
  try {
4571
4680
  const parsed = JSON.parse(
4572
- readFileSync7(path3, "utf8")
4681
+ readFileSync8(path3, "utf8")
4573
4682
  );
4574
4683
  if (parsed?.version === 1 && parsed.attachments && typeof parsed.attachments === "object") {
4575
4684
  return parsed;
@@ -4579,15 +4688,15 @@ function loadManifest(dir) {
4579
4688
  return { version: 1, attachments: {} };
4580
4689
  }
4581
4690
  function saveManifest(dir, manifest) {
4582
- writeFileSync6(
4583
- join6(dir, MANIFEST_FILE2),
4691
+ writeFileSync7(
4692
+ join7(dir, MANIFEST_FILE2),
4584
4693
  `${JSON.stringify(manifest, null, 2)}
4585
4694
  `,
4586
4695
  "utf8"
4587
4696
  );
4588
4697
  }
4589
4698
  function isAttachmentUpToDate(entry, item, dest) {
4590
- if (!entry || !existsSync9(dest)) return false;
4699
+ if (!entry || !existsSync10(dest)) return false;
4591
4700
  if (entry.name !== item.name) return false;
4592
4701
  const createdAt = item.createdAt ?? "";
4593
4702
  return entry.createdAt === createdAt;
@@ -4602,7 +4711,7 @@ async function syncAttachmentsToDirectory(cfg2, attachments, dir, logLabel) {
4602
4711
  const nextManifest = { version: 1, attachments: {} };
4603
4712
  const names = [];
4604
4713
  for (const item of attachments) {
4605
- const dest = join6(dir, item.name);
4714
+ const dest = join7(dir, item.name);
4606
4715
  const entry = manifest.attachments[item.id];
4607
4716
  const createdAt = item.createdAt ?? "";
4608
4717
  names.push(item.name);
@@ -4612,7 +4721,7 @@ async function syncAttachmentsToDirectory(cfg2, attachments, dir, logLabel) {
4612
4721
  continue;
4613
4722
  }
4614
4723
  const buffer = await downloadAttachment(cfg2, item.id);
4615
- writeFileSync6(dest, buffer);
4724
+ writeFileSync7(dest, buffer);
4616
4725
  nextManifest.attachments[item.id] = {
4617
4726
  name: item.name,
4618
4727
  createdAt
@@ -4633,9 +4742,9 @@ async function syncWebIdeAttachments(cfg2, taskId, workdir, attachments) {
4633
4742
  }
4634
4743
 
4635
4744
  // src/commands/sync-webide-design.ts
4636
- import { createHash as createHash3 } from "crypto";
4637
- import { existsSync as existsSync10, readdirSync as readdirSync5, readFileSync as readFileSync8, statSync as statSync5, writeFileSync as writeFileSync7 } from "fs";
4638
- import { join as join7 } from "path";
4745
+ import { createHash as createHash4 } from "crypto";
4746
+ import { existsSync as existsSync11, readdirSync as readdirSync5, readFileSync as readFileSync9, statSync as statSync5, writeFileSync as writeFileSync8 } from "fs";
4747
+ import { join as join8 } from "path";
4639
4748
 
4640
4749
  // src/opc-shared-types.ts
4641
4750
  function webIdeDesignObjectKey(taskId, fileName) {
@@ -4653,15 +4762,15 @@ function webIdeDesignArtifactContentType(name) {
4653
4762
  // src/commands/sync-webide-design.ts
4654
4763
  var MANIFEST_FILE3 = ".sync-manifest.json";
4655
4764
  function hashBuffer(buf) {
4656
- return createHash3("sha256").update(buf).digest("hex");
4765
+ return createHash4("sha256").update(buf).digest("hex");
4657
4766
  }
4658
4767
  function loadManifest2(dir) {
4659
- const path3 = join7(dir, MANIFEST_FILE3);
4660
- if (!existsSync10(path3)) {
4768
+ const path3 = join8(dir, MANIFEST_FILE3);
4769
+ if (!existsSync11(path3)) {
4661
4770
  return { version: 1, files: {} };
4662
4771
  }
4663
4772
  try {
4664
- const parsed = JSON.parse(readFileSync8(path3, "utf8"));
4773
+ const parsed = JSON.parse(readFileSync9(path3, "utf8"));
4665
4774
  if (parsed?.version === 1 && parsed.files && typeof parsed.files === "object") {
4666
4775
  return parsed;
4667
4776
  }
@@ -4670,8 +4779,8 @@ function loadManifest2(dir) {
4670
4779
  return { version: 1, files: {} };
4671
4780
  }
4672
4781
  function saveManifest2(dir, manifest) {
4673
- writeFileSync7(
4674
- join7(dir, MANIFEST_FILE3),
4782
+ writeFileSync8(
4783
+ join8(dir, MANIFEST_FILE3),
4675
4784
  `${JSON.stringify(manifest, null, 2)}
4676
4785
  `,
4677
4786
  "utf8"
@@ -4699,13 +4808,13 @@ async function syncWebIdeDesign(cfg2, taskId, workdir, artifacts) {
4699
4808
  for (const art of artifacts) {
4700
4809
  const name = art.name?.trim();
4701
4810
  if (!name || !isWebIdeDesignArtifactName(name)) continue;
4702
- const localPath = join7(dir, name);
4811
+ const localPath = join8(dir, name);
4703
4812
  const entry = manifest.files[name];
4704
- if (entry?.contentHash === art.contentHash && existsSync10(localPath)) {
4813
+ if (entry?.contentHash === art.contentHash && existsSync11(localPath)) {
4705
4814
  continue;
4706
4815
  }
4707
4816
  const buf = await downloadDesignFile(cfg2, taskId, name);
4708
- writeFileSync7(localPath, buf);
4817
+ writeFileSync8(localPath, buf);
4709
4818
  manifest.files[name] = { contentHash: hashBuffer(buf) };
4710
4819
  synced.push(name);
4711
4820
  }
@@ -4714,13 +4823,13 @@ async function syncWebIdeDesign(cfg2, taskId, workdir, artifacts) {
4714
4823
  }
4715
4824
  function listLocalDesignArtifactFiles(taskId, workdir) {
4716
4825
  const dir = webideDesignDir(taskId, workdir);
4717
- if (!existsSync10(dir)) return [];
4826
+ if (!existsSync11(dir)) return [];
4718
4827
  const out = [];
4719
4828
  for (const name of readdirSync5(dir)) {
4720
4829
  if (!isWebIdeDesignArtifactName(name)) continue;
4721
- const absPath = join7(dir, name);
4830
+ const absPath = join8(dir, name);
4722
4831
  if (!statSync5(absPath).isFile()) continue;
4723
- const buf = readFileSync8(absPath);
4832
+ const buf = readFileSync9(absPath);
4724
4833
  if (buf.length === 0) continue;
4725
4834
  out.push({ name, absPath, contentHash: hashBuffer(buf) });
4726
4835
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-project-manage-cli",
3
- "version": "8.1.12",
3
+ "version": "8.1.13",
4
4
  "description": "命令行工具:后续用于调用平台后端 API 完成运维与自动化操作",
5
5
  "type": "module",
6
6
  "private": false,