ai-project-manage-cli 7.1.17 → 7.1.18

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
@@ -333,13 +333,13 @@ var init_client = __esm({
333
333
  });
334
334
 
335
335
  // src/commands/deploy/internal/minio.ts
336
- import { statSync as statSync5 } from "node:fs";
336
+ import { statSync as statSync6 } from "node:fs";
337
337
  import { readdir, readFile } from "node:fs/promises";
338
338
  import path from "node:path";
339
339
  import * as Minio from "minio";
340
340
  async function isDirectoryPath(dir) {
341
341
  try {
342
- const st = statSync5(dir);
342
+ const st = statSync6(dir);
343
343
  return st.isDirectory();
344
344
  } catch {
345
345
  return false;
@@ -369,7 +369,7 @@ async function collectFiles(root) {
369
369
  if (e.isDirectory()) {
370
370
  await walk(abs, rel);
371
371
  } else if (e.isFile()) {
372
- const st = statSync5(abs);
372
+ const st = statSync6(abs);
373
373
  out.push({
374
374
  absPath: abs,
375
375
  relativePath: rel.replace(/\\/g, "/"),
@@ -436,14 +436,14 @@ var init_minio = __esm({
436
436
  async deleteObjectsByPrefix(bucket, prefix) {
437
437
  const objectsStream = this.inner.listObjectsV2(bucket, prefix, true);
438
438
  const keys = [];
439
- await new Promise((resolve7, reject) => {
439
+ await new Promise((resolve8, reject) => {
440
440
  objectsStream.on("data", (obj) => {
441
441
  if (obj.name) {
442
442
  keys.push(obj.name);
443
443
  }
444
444
  });
445
445
  objectsStream.on("error", reject);
446
- objectsStream.on("end", resolve7);
446
+ objectsStream.on("end", resolve8);
447
447
  });
448
448
  const chunkSize = 500;
449
449
  for (let i = 0; i < keys.length; i += chunkSize) {
@@ -1395,6 +1395,36 @@ import { writeFileSync as writeFileSync3 } from "fs";
1395
1395
  import { execFile } from "child_process";
1396
1396
  import { promisify } from "util";
1397
1397
  var execFileAsync = promisify(execFile);
1398
+ function toHttpsGitRemoteUrl(raw) {
1399
+ let s = raw.trim();
1400
+ if (!s) return null;
1401
+ const sshScp = /^git@([^:]+):(.+)$/.exec(s);
1402
+ if (sshScp) {
1403
+ s = `https://${sshScp[1]}/${sshScp[2]}`;
1404
+ } else {
1405
+ const sshUri = /^ssh:\/\/(?:git@)?([^/]+)\/(.+)$/i.exec(s);
1406
+ if (sshUri) {
1407
+ s = `https://${sshUri[1]}/${sshUri[2]}`;
1408
+ } else if (/^http:\/\//i.test(s)) {
1409
+ s = `https://${s.slice("http://".length)}`;
1410
+ } else if (!/^https:\/\//i.test(s)) {
1411
+ const scpLike = /^([^/:]+):(.+)$/.exec(s);
1412
+ if (scpLike && !scpLike[1].includes(".")) {
1413
+ return null;
1414
+ }
1415
+ if (scpLike) {
1416
+ s = `https://${scpLike[1]}/${scpLike[2]}`;
1417
+ } else if (s.includes("/")) {
1418
+ s = `https://${s}`;
1419
+ } else {
1420
+ return null;
1421
+ }
1422
+ }
1423
+ }
1424
+ s = s.replace(/\/+$/, "");
1425
+ if (!/^https:\/\//i.test(s)) return null;
1426
+ return s;
1427
+ }
1398
1428
  async function tryReadGitOriginUrl(cwd) {
1399
1429
  try {
1400
1430
  const { stdout } = await execFileAsync(
@@ -1408,6 +1438,11 @@ async function tryReadGitOriginUrl(cwd) {
1408
1438
  return null;
1409
1439
  }
1410
1440
  }
1441
+ async function tryReadHttpsGitOriginUrl(cwd) {
1442
+ const raw = await tryReadGitOriginUrl(cwd);
1443
+ if (!raw) return null;
1444
+ return toHttpsGitRemoteUrl(raw);
1445
+ }
1411
1446
 
1412
1447
  // src/git-utils.ts
1413
1448
  import { execFile as execFile2 } from "child_process";
@@ -1470,6 +1505,24 @@ async function ensureRemoteBaselineBranch(cwd, baselineBranch) {
1470
1505
  `[apm] \u8FDC\u7A0B\u4E0D\u5B58\u5728\u57FA\u7EBF\u5206\u652F origin/${baselineBranch}\uFF0C\u8BF7\u786E\u8BA4\u4ED3\u5E93\u9ED8\u8BA4\u5206\u652F\u5DF2\u63A8\u9001\u5230 origin`
1471
1506
  );
1472
1507
  }
1508
+ async function resolveDefaultRemoteBranch(cwd) {
1509
+ try {
1510
+ const ref = (await execGit(cwd, ["symbolic-ref", "refs/remotes/origin/HEAD"], true)).trim();
1511
+ const match = ref.match(/^refs\/remotes\/origin\/(.+)$/);
1512
+ if (match?.[1]) {
1513
+ return match[1];
1514
+ }
1515
+ } catch {
1516
+ }
1517
+ for (const candidate of ["main", "master"]) {
1518
+ if (await remoteBranchExists(cwd, candidate)) {
1519
+ return candidate;
1520
+ }
1521
+ }
1522
+ throw new Error(
1523
+ "[apm] \u65E0\u6CD5\u786E\u5B9A\u8FDC\u7A0B\u9ED8\u8BA4\u5206\u652F\uFF08origin/HEAD\u3001main\u3001master \u5747\u4E0D\u53EF\u7528\uFF09"
1524
+ );
1525
+ }
1473
1526
  async function hasUpstream(cwd) {
1474
1527
  try {
1475
1528
  await execGit(cwd, ["rev-parse", "--abbrev-ref", "@{upstream}"], true);
@@ -1707,16 +1760,16 @@ function hashLocalFileContent(content) {
1707
1760
  return createHash("sha256").update(content, "utf8").digest("hex");
1708
1761
  }
1709
1762
  function readLocalManifest(apmRoot, projectId) {
1710
- const manifestPath2 = join4(
1763
+ const manifestPath3 = join4(
1711
1764
  projectDocumentsDir(apmRoot, projectId),
1712
1765
  MANIFEST_FILE
1713
1766
  );
1714
- if (!existsSync2(manifestPath2)) {
1767
+ if (!existsSync2(manifestPath3)) {
1715
1768
  return null;
1716
1769
  }
1717
1770
  try {
1718
1771
  return JSON.parse(
1719
- readFileSync3(manifestPath2, "utf8")
1772
+ readFileSync3(manifestPath3, "utf8")
1720
1773
  );
1721
1774
  } catch {
1722
1775
  return null;
@@ -2045,6 +2098,162 @@ async function runLogin(opts) {
2045
2098
 
2046
2099
  // src/commands/branch.ts
2047
2100
  init_client();
2101
+
2102
+ // src/workspace-repos.ts
2103
+ import {
2104
+ existsSync as existsSync4,
2105
+ mkdirSync as mkdirSync3,
2106
+ readFileSync as readFileSync5,
2107
+ readdirSync as readdirSync3,
2108
+ statSync as statSync2,
2109
+ writeFileSync as writeFileSync6
2110
+ } from "fs";
2111
+ import { basename as basename2, dirname as dirname3, join as join6, relative as relative2, resolve as resolve3 } from "path";
2112
+ var WORKSPACE_REPOS_MANIFEST = "workspace-repos.json";
2113
+ var WORKSPACE_REPOS_VERSION = 1;
2114
+ function manifestPath(workdir) {
2115
+ return join6(workspaceApmDir(workdir), WORKSPACE_REPOS_MANIFEST);
2116
+ }
2117
+ function absoluteRepoPath(workdir, entry) {
2118
+ if (entry.path === "." || entry.path === "") {
2119
+ return workdir;
2120
+ }
2121
+ return resolve3(workdir, entry.path);
2122
+ }
2123
+ function normalizeRepoEntry(raw) {
2124
+ if (!raw || typeof raw !== "object") return null;
2125
+ const o = raw;
2126
+ if (typeof o.path !== "string" || !o.path.trim()) return null;
2127
+ const entry = {
2128
+ path: o.path.trim().replace(/\\/g, "/")
2129
+ };
2130
+ if (typeof o.remoteUrl === "string" && o.remoteUrl.trim()) {
2131
+ entry.remoteUrl = o.remoteUrl.trim();
2132
+ } else if (o.remoteUrl === null) {
2133
+ entry.remoteUrl = null;
2134
+ }
2135
+ return entry;
2136
+ }
2137
+ function readManifest(workdir) {
2138
+ const path19 = toFsPath(manifestPath(workdir));
2139
+ if (!existsSync4(path19)) {
2140
+ return null;
2141
+ }
2142
+ try {
2143
+ const raw = JSON.parse(
2144
+ readFileSync5(path19, "utf8")
2145
+ );
2146
+ if (raw?.version !== WORKSPACE_REPOS_VERSION) {
2147
+ return null;
2148
+ }
2149
+ if (raw.kind !== "single" && raw.kind !== "multi") {
2150
+ return null;
2151
+ }
2152
+ if (!Array.isArray(raw.repos) || raw.repos.length === 0) {
2153
+ return null;
2154
+ }
2155
+ if (typeof raw.workdir !== "string" || !raw.workdir.trim()) {
2156
+ return null;
2157
+ }
2158
+ const repos = raw.repos.map((item) => normalizeRepoEntry(item)).filter((item) => item != null);
2159
+ if (repos.length === 0) {
2160
+ return null;
2161
+ }
2162
+ return {
2163
+ version: WORKSPACE_REPOS_VERSION,
2164
+ kind: raw.kind,
2165
+ workdir: raw.workdir,
2166
+ repos,
2167
+ scannedAt: typeof raw.scannedAt === "string" && raw.scannedAt.trim() ? raw.scannedAt : (/* @__PURE__ */ new Date()).toISOString()
2168
+ };
2169
+ } catch {
2170
+ return null;
2171
+ }
2172
+ }
2173
+ function writeManifest(workdir, manifest) {
2174
+ const apmDir = toFsPath(workspaceApmDir(workdir));
2175
+ mkdirSync3(apmDir, { recursive: true });
2176
+ const path19 = toFsPath(manifestPath(workdir));
2177
+ writeFileSync6(path19, `${JSON.stringify(manifest, null, 2)}
2178
+ `, "utf8");
2179
+ }
2180
+ function isPathInsideOrEqual(parentAbs, childAbs) {
2181
+ const parent = normalizeWorkdirPath(parentAbs);
2182
+ const child = normalizeWorkdirPath(childAbs);
2183
+ if (child === parent) return true;
2184
+ const prefix = parent.endsWith("/") ? parent : `${parent}/`;
2185
+ return child.startsWith(prefix);
2186
+ }
2187
+ function findWorkspaceReposManifestNearPath(startDirInput) {
2188
+ let current = resolve3(startDirInput);
2189
+ for (; ; ) {
2190
+ const candidates = /* @__PURE__ */ new Set([normalizeWorkdirPath(current)]);
2191
+ try {
2192
+ if (existsSync4(toFsPath(current))) {
2193
+ candidates.add(resolveWorkdirPath(current));
2194
+ }
2195
+ } catch {
2196
+ }
2197
+ for (const candidate of candidates) {
2198
+ const cached = readManifest(candidate);
2199
+ if (!cached) continue;
2200
+ const cachedWorkdir = resolveWorkdirPath(cached.workdir);
2201
+ const candidateNorm = resolveWorkdirPath(candidate);
2202
+ if (cachedWorkdir === candidateNorm) {
2203
+ return { ...cached, workdir: cachedWorkdir };
2204
+ }
2205
+ }
2206
+ const parent = dirname3(current);
2207
+ if (parent === current) {
2208
+ return null;
2209
+ }
2210
+ current = parent;
2211
+ }
2212
+ }
2213
+ function matchWorkspaceRepoEntryForPath(manifest, pathInput) {
2214
+ const target = resolveWorkdirPath(pathInput);
2215
+ const workdir = resolveWorkdirPath(manifest.workdir);
2216
+ let best = null;
2217
+ let bestLen = -1;
2218
+ for (const entry of manifest.repos) {
2219
+ const abs = resolveWorkdirPath(absoluteRepoPath(workdir, entry));
2220
+ if (!isPathInsideOrEqual(abs, target)) {
2221
+ continue;
2222
+ }
2223
+ if (abs.length > bestLen) {
2224
+ best = entry;
2225
+ bestLen = abs.length;
2226
+ }
2227
+ }
2228
+ return best;
2229
+ }
2230
+ async function enrichWorkspaceReposRemoteUrls(manifest) {
2231
+ let changed = false;
2232
+ const repos = [];
2233
+ for (const entry of manifest.repos) {
2234
+ const abs = absoluteRepoPath(manifest.workdir, entry);
2235
+ const remoteUrl = await tryReadHttpsGitOriginUrl(abs);
2236
+ const next = {
2237
+ path: entry.path,
2238
+ remoteUrl: remoteUrl || null
2239
+ };
2240
+ if ((entry.remoteUrl ?? null) !== next.remoteUrl) {
2241
+ changed = true;
2242
+ }
2243
+ repos.push(next);
2244
+ }
2245
+ const nextManifest = {
2246
+ ...manifest,
2247
+ repos,
2248
+ scannedAt: changed ? (/* @__PURE__ */ new Date()).toISOString() : manifest.scannedAt
2249
+ };
2250
+ if (changed) {
2251
+ writeManifest(manifest.workdir, nextManifest);
2252
+ }
2253
+ return nextManifest;
2254
+ }
2255
+
2256
+ // src/commands/branch.ts
2048
2257
  var SESSION_BRANCH_PREFIX = "feat/session-";
2049
2258
  function branchNameForSession(sessionId) {
2050
2259
  const id = sessionId.trim();
@@ -2494,8 +2703,8 @@ async function runCleanBranches(options = {}) {
2494
2703
 
2495
2704
  // src/commands/pull.ts
2496
2705
  init_client();
2497
- import { writeFileSync as writeFileSync9 } from "fs";
2498
- import { join as join9 } from "path";
2706
+ import { writeFileSync as writeFileSync10 } from "fs";
2707
+ import { join as join10 } from "path";
2499
2708
  import { stringify as yamlStringify } from "yaml";
2500
2709
 
2501
2710
  // src/session-messages-xml.ts
@@ -2528,8 +2737,8 @@ function formatSessionMessagesXml(sessionId, messages) {
2528
2737
  }
2529
2738
 
2530
2739
  // src/commands/sync-session-attachments.ts
2531
- import { existsSync as existsSync4, readFileSync as readFileSync5, writeFileSync as writeFileSync6 } from "fs";
2532
- import { join as join6 } from "path";
2740
+ import { existsSync as existsSync5, readFileSync as readFileSync6, writeFileSync as writeFileSync7 } from "fs";
2741
+ import { join as join7 } from "path";
2533
2742
  var MANIFEST_FILE2 = ".sync-manifest.json";
2534
2743
  async function downloadAttachment(cfg, attachmentId) {
2535
2744
  const base = cfg.baseUrl.trim().replace(/\/+$/, "");
@@ -2545,13 +2754,13 @@ async function downloadAttachment(cfg, attachmentId) {
2545
2754
  return Buffer.from(await res.arrayBuffer());
2546
2755
  }
2547
2756
  function loadManifest(dir) {
2548
- const path19 = join6(dir, MANIFEST_FILE2);
2549
- if (!existsSync4(path19)) {
2757
+ const path19 = join7(dir, MANIFEST_FILE2);
2758
+ if (!existsSync5(path19)) {
2550
2759
  return { version: 1, attachments: {} };
2551
2760
  }
2552
2761
  try {
2553
2762
  const parsed = JSON.parse(
2554
- readFileSync5(path19, "utf8")
2763
+ readFileSync6(path19, "utf8")
2555
2764
  );
2556
2765
  if (parsed?.version === 1 && parsed.attachments && typeof parsed.attachments === "object") {
2557
2766
  return parsed;
@@ -2561,15 +2770,15 @@ function loadManifest(dir) {
2561
2770
  return { version: 1, attachments: {} };
2562
2771
  }
2563
2772
  function saveManifest(dir, manifest) {
2564
- writeFileSync6(
2565
- join6(dir, MANIFEST_FILE2),
2773
+ writeFileSync7(
2774
+ join7(dir, MANIFEST_FILE2),
2566
2775
  `${JSON.stringify(manifest, null, 2)}
2567
2776
  `,
2568
2777
  "utf8"
2569
2778
  );
2570
2779
  }
2571
2780
  function isAttachmentUpToDate(entry, item, dest) {
2572
- if (!entry || !existsSync4(dest)) return false;
2781
+ if (!entry || !existsSync5(dest)) return false;
2573
2782
  if (entry.name !== item.name) return false;
2574
2783
  const createdAt = item.createdAt ?? "";
2575
2784
  return entry.createdAt === createdAt;
@@ -2584,7 +2793,7 @@ async function syncAttachmentsToDirectory(cfg, attachments, dir, logLabel) {
2584
2793
  const nextManifest = { version: 1, attachments: {} };
2585
2794
  const names = [];
2586
2795
  for (const item of attachments) {
2587
- const dest = join6(dir, item.name);
2796
+ const dest = join7(dir, item.name);
2588
2797
  const entry = manifest.attachments[item.id];
2589
2798
  const createdAt = item.createdAt ?? "";
2590
2799
  names.push(item.name);
@@ -2594,7 +2803,7 @@ async function syncAttachmentsToDirectory(cfg, attachments, dir, logLabel) {
2594
2803
  continue;
2595
2804
  }
2596
2805
  const buffer = await downloadAttachment(cfg, item.id);
2597
- writeFileSync6(dest, buffer);
2806
+ writeFileSync7(dest, buffer);
2598
2807
  nextManifest.attachments[item.id] = {
2599
2808
  name: item.name,
2600
2809
  createdAt
@@ -2605,7 +2814,7 @@ async function syncAttachmentsToDirectory(cfg, attachments, dir, logLabel) {
2605
2814
  return names;
2606
2815
  }
2607
2816
  async function syncSessionAttachments(cfg, sessionId, attachments, apmRoot) {
2608
- const dir = join6(sessionDir(sessionId, apmRoot), SESSION_ATTACHMENTS_SUBDIR);
2817
+ const dir = join7(sessionDir(sessionId, apmRoot), SESSION_ATTACHMENTS_SUBDIR);
2609
2818
  return syncAttachmentsToDirectory(
2610
2819
  cfg,
2611
2820
  attachments,
@@ -2616,65 +2825,65 @@ async function syncSessionAttachments(cfg, sessionId, attachments, apmRoot) {
2616
2825
 
2617
2826
  // src/rules-sync.ts
2618
2827
  init_client();
2619
- import { basename as basename2, extname as extname2, join as join8 } from "path";
2620
- import { existsSync as existsSync6, readFileSync as readFileSync6, rmSync as rmSync3, writeFileSync as writeFileSync8 } from "fs";
2828
+ import { basename as basename3, extname as extname2, join as join9 } from "path";
2829
+ import { existsSync as existsSync7, readFileSync as readFileSync7, rmSync as rmSync3, writeFileSync as writeFileSync9 } from "fs";
2621
2830
 
2622
2831
  // src/skills-sync.ts
2623
2832
  import {
2624
2833
  copyFileSync as copyFileSync2,
2625
2834
  cpSync,
2626
- existsSync as existsSync5,
2627
- mkdirSync as mkdirSync3,
2628
- readdirSync as readdirSync3,
2835
+ existsSync as existsSync6,
2836
+ mkdirSync as mkdirSync4,
2837
+ readdirSync as readdirSync4,
2629
2838
  rmSync as rmSync2,
2630
- statSync as statSync2,
2631
- writeFileSync as writeFileSync7
2839
+ statSync as statSync3,
2840
+ writeFileSync as writeFileSync8
2632
2841
  } from "fs";
2633
- import { join as join7 } from "path";
2634
- var AGENTS_TEMPLATE_PATH = join7(CLI_TEMPLATE_DIR, "AGENTS.md");
2635
- var BASE_SKILLS_TEMPLATE_DIR = join7(CLI_TEMPLATE_DIR, "skills");
2636
- var BASE_RULES_TEMPLATE_DIR = join7(CLI_TEMPLATE_DIR, "rules");
2842
+ import { join as join8 } from "path";
2843
+ var AGENTS_TEMPLATE_PATH = join8(CLI_TEMPLATE_DIR, "AGENTS.md");
2844
+ var BASE_SKILLS_TEMPLATE_DIR = join8(CLI_TEMPLATE_DIR, "skills");
2845
+ var BASE_RULES_TEMPLATE_DIR = join8(CLI_TEMPLATE_DIR, "rules");
2637
2846
  function sanitizeSkillDirName(name) {
2638
2847
  const trimmed = name.trim();
2639
2848
  if (!trimmed) return "skill";
2640
2849
  return trimmed.replace(/[/\\:*?"<>|]/g, "_");
2641
2850
  }
2642
2851
  function listBaseSkillDirNames() {
2643
- if (!existsSync5(BASE_SKILLS_TEMPLATE_DIR)) return [];
2644
- return readdirSync3(BASE_SKILLS_TEMPLATE_DIR).filter((name) => {
2645
- const path19 = join7(BASE_SKILLS_TEMPLATE_DIR, name);
2646
- return statSync2(path19).isDirectory();
2852
+ if (!existsSync6(BASE_SKILLS_TEMPLATE_DIR)) return [];
2853
+ return readdirSync4(BASE_SKILLS_TEMPLATE_DIR).filter((name) => {
2854
+ const path19 = join8(BASE_SKILLS_TEMPLATE_DIR, name);
2855
+ return statSync3(path19).isDirectory();
2647
2856
  });
2648
2857
  }
2649
2858
  function syncAgentsGuide(apmDir) {
2650
- if (!existsSync5(AGENTS_TEMPLATE_PATH)) return false;
2651
- mkdirSync3(apmDir, { recursive: true });
2652
- copyFileSync2(AGENTS_TEMPLATE_PATH, join7(apmDir, "AGENTS.md"));
2859
+ if (!existsSync6(AGENTS_TEMPLATE_PATH)) return false;
2860
+ mkdirSync4(apmDir, { recursive: true });
2861
+ copyFileSync2(AGENTS_TEMPLATE_PATH, join8(apmDir, "AGENTS.md"));
2653
2862
  return true;
2654
2863
  }
2655
2864
  function listBaseRuleFileNames() {
2656
- if (!existsSync5(BASE_RULES_TEMPLATE_DIR)) return [];
2657
- return readdirSync3(BASE_RULES_TEMPLATE_DIR).filter((name) => {
2658
- const path19 = join7(BASE_RULES_TEMPLATE_DIR, name);
2659
- return statSync2(path19).isFile();
2865
+ if (!existsSync6(BASE_RULES_TEMPLATE_DIR)) return [];
2866
+ return readdirSync4(BASE_RULES_TEMPLATE_DIR).filter((name) => {
2867
+ const path19 = join8(BASE_RULES_TEMPLATE_DIR, name);
2868
+ return statSync3(path19).isFile();
2660
2869
  });
2661
2870
  }
2662
2871
  function syncBaseRules(rulesDir) {
2663
- mkdirSync3(rulesDir, { recursive: true });
2872
+ mkdirSync4(rulesDir, { recursive: true });
2664
2873
  const names = listBaseRuleFileNames();
2665
2874
  for (const name of names) {
2666
- const src = join7(BASE_RULES_TEMPLATE_DIR, name);
2667
- const dest = join7(rulesDir, name);
2875
+ const src = join8(BASE_RULES_TEMPLATE_DIR, name);
2876
+ const dest = join8(rulesDir, name);
2668
2877
  copyFileSync2(src, dest);
2669
2878
  }
2670
2879
  return names;
2671
2880
  }
2672
2881
  function syncBaseSkills(skillsDir) {
2673
- mkdirSync3(skillsDir, { recursive: true });
2882
+ mkdirSync4(skillsDir, { recursive: true });
2674
2883
  const names = listBaseSkillDirNames();
2675
2884
  for (const name of names) {
2676
- const src = join7(BASE_SKILLS_TEMPLATE_DIR, name);
2677
- const dest = join7(skillsDir, name);
2885
+ const src = join8(BASE_SKILLS_TEMPLATE_DIR, name);
2886
+ const dest = join8(skillsDir, name);
2678
2887
  cpSync(src, dest, { recursive: true, force: true });
2679
2888
  }
2680
2889
  return names;
@@ -2691,16 +2900,16 @@ function syncSupplementarySkills(skillsDir, list) {
2691
2900
  skipped.push(dirName);
2692
2901
  continue;
2693
2902
  }
2694
- const skillDir = join7(skillsDir, dirName);
2695
- mkdirSync3(skillDir, { recursive: true });
2696
- writeFileSync7(join7(skillDir, "SKILL.md"), skill.content ?? "", "utf8");
2903
+ const skillDir = join8(skillsDir, dirName);
2904
+ mkdirSync4(skillDir, { recursive: true });
2905
+ writeFileSync8(join8(skillDir, "SKILL.md"), skill.content ?? "", "utf8");
2697
2906
  written.push(dirName);
2698
2907
  }
2699
2908
  const removed = [];
2700
- if (!existsSync5(skillsDir)) return { written, skipped, removed };
2701
- for (const entry of readdirSync3(skillsDir)) {
2702
- const full = join7(skillsDir, entry);
2703
- if (!statSync2(full).isDirectory()) continue;
2909
+ if (!existsSync6(skillsDir)) return { written, skipped, removed };
2910
+ for (const entry of readdirSync4(skillsDir)) {
2911
+ const full = join8(skillsDir, entry);
2912
+ if (!statSync3(full).isDirectory()) continue;
2704
2913
  if (baseNames.has(entry)) continue;
2705
2914
  if (apiDirNames.has(entry)) continue;
2706
2915
  rmSync2(full, { recursive: true, force: true });
@@ -2719,13 +2928,13 @@ function ruleLocalFileName(ruleName) {
2719
2928
  return `${sanitized}.md`;
2720
2929
  }
2721
2930
  function loadManifest2(rulesDir) {
2722
- const path19 = join8(rulesDir, MANIFEST_FILE3);
2723
- if (!existsSync6(toFsPath(path19))) {
2931
+ const path19 = join9(rulesDir, MANIFEST_FILE3);
2932
+ if (!existsSync7(toFsPath(path19))) {
2724
2933
  return { version: 1, rules: {} };
2725
2934
  }
2726
2935
  try {
2727
2936
  const parsed = JSON.parse(
2728
- readFileSync6(toFsPath(path19), "utf8")
2937
+ readFileSync7(toFsPath(path19), "utf8")
2729
2938
  );
2730
2939
  if (parsed?.version === 1 && parsed.rules && typeof parsed.rules === "object") {
2731
2940
  return parsed;
@@ -2735,29 +2944,29 @@ function loadManifest2(rulesDir) {
2735
2944
  return { version: 1, rules: {} };
2736
2945
  }
2737
2946
  function saveManifest2(rulesDir, manifest) {
2738
- writeFileSync8(
2739
- toFsPath(join8(rulesDir, MANIFEST_FILE3)),
2947
+ writeFileSync9(
2948
+ toFsPath(join9(rulesDir, MANIFEST_FILE3)),
2740
2949
  `${JSON.stringify(manifest, null, 2)}
2741
2950
  `,
2742
2951
  "utf8"
2743
2952
  );
2744
2953
  }
2745
2954
  function isBaseRuleFileName(fileName) {
2746
- return listBaseRuleFileNames().includes(basename2(fileName));
2955
+ return listBaseRuleFileNames().includes(basename3(fileName));
2747
2956
  }
2748
2957
  function isRuleUpToDate(entry, rule, dest) {
2749
- if (!entry || !existsSync6(toFsPath(dest))) return false;
2958
+ if (!entry || !existsSync7(toFsPath(dest))) return false;
2750
2959
  if (entry.fileName !== ruleLocalFileName(rule.name)) return false;
2751
2960
  const updatedAt = rule.updatedAt ?? "";
2752
2961
  if (entry.updatedAt !== updatedAt) return false;
2753
- const localContent = readFileSync6(toFsPath(dest), "utf8");
2962
+ const localContent = readFileSync7(toFsPath(dest), "utf8");
2754
2963
  return localContent === (rule.content ?? "");
2755
2964
  }
2756
2965
  async function syncPlatformRules(cfg, sessionId, workdirPath, apmRoot) {
2757
2966
  const api = createApmApiClient(cfg);
2758
2967
  const baseline = await resolveBranchBaseline(api, sessionId, workdirPath);
2759
2968
  const repositoryId = baseline.repositoryId;
2760
- const rulesDir = join8(apmRoot ?? workspaceApmDir(workdirPath), "rules");
2969
+ const rulesDir = join9(apmRoot ?? workspaceApmDir(workdirPath), "rules");
2761
2970
  await ensureDirExists(rulesDir);
2762
2971
  if (!repositoryId) {
2763
2972
  console.log(
@@ -2774,7 +2983,7 @@ async function syncPlatformRules(cfg, sessionId, workdirPath, apmRoot) {
2774
2983
  for (const rule of list) {
2775
2984
  remoteIds.add(rule.id);
2776
2985
  const fileName = ruleLocalFileName(rule.name);
2777
- const dest = join8(rulesDir, fileName);
2986
+ const dest = join9(rulesDir, fileName);
2778
2987
  const entry = manifest.rules[rule.id];
2779
2988
  const updatedAt = rule.updatedAt ?? "";
2780
2989
  if (isRuleUpToDate(entry, rule, dest)) {
@@ -2783,7 +2992,7 @@ async function syncPlatformRules(cfg, sessionId, workdirPath, apmRoot) {
2783
2992
  console.log(`[apm] \u89C4\u5219\u65E0\u53D8\u5316\uFF0C\u5DF2\u8DF3\u8FC7: rules/${fileName}`);
2784
2993
  continue;
2785
2994
  }
2786
- writeFileSync8(toFsPath(dest), rule.content ?? "", "utf8");
2995
+ writeFileSync9(toFsPath(dest), rule.content ?? "", "utf8");
2787
2996
  nextManifest.rules[rule.id] = { fileName, updatedAt };
2788
2997
  written.push(fileName);
2789
2998
  console.log(`[apm] \u5DF2\u540C\u6B65\u5E73\u53F0\u89C4\u5219: rules/${fileName}`);
@@ -2792,8 +3001,8 @@ async function syncPlatformRules(cfg, sessionId, workdirPath, apmRoot) {
2792
3001
  for (const [ruleId, entry] of Object.entries(manifest.rules)) {
2793
3002
  if (remoteIds.has(ruleId)) continue;
2794
3003
  if (isBaseRuleFileName(entry.fileName)) continue;
2795
- const dest = join8(rulesDir, entry.fileName);
2796
- if (existsSync6(toFsPath(dest))) {
3004
+ const dest = join9(rulesDir, entry.fileName);
3005
+ if (existsSync7(toFsPath(dest))) {
2797
3006
  rmSync3(toFsPath(dest), { force: true });
2798
3007
  }
2799
3008
  removed.push(entry.fileName);
@@ -2824,20 +3033,20 @@ async function runPull(sessionId, remoteWorkdir) {
2824
3033
  const dir = sessionDir(trimmedId, apmRoot);
2825
3034
  const docsDir = sessionDocsDir(trimmedId, apmRoot);
2826
3035
  await ensureDirExists(docsDir);
2827
- writeFileSync9(
3036
+ writeFileSync10(
2828
3037
  sessionRulePath(trimmedId, apmRoot),
2829
3038
  detail.description ?? "",
2830
3039
  "utf8"
2831
3040
  );
2832
- writeFileSync9(
3041
+ writeFileSync10(
2833
3042
  sessionTaskPath(trimmedId, apmRoot),
2834
3043
  detail.task.description ?? "",
2835
3044
  "utf8"
2836
3045
  );
2837
- writeFileSync9(sessionTodoPath(trimmedId, apmRoot), detail.todo ?? "", "utf8");
3046
+ writeFileSync10(sessionTodoPath(trimmedId, apmRoot), detail.todo ?? "", "utf8");
2838
3047
  for (const doc of documents) {
2839
3048
  const fileName = documentLocalFileName(doc.name);
2840
- writeFileSync9(join9(docsDir, fileName), doc.content ?? "", "utf8");
3049
+ writeFileSync10(join10(docsDir, fileName), doc.content ?? "", "utf8");
2841
3050
  }
2842
3051
  const sessionYaml = yamlStringify(
2843
3052
  {
@@ -2854,13 +3063,13 @@ async function runPull(sessionId, remoteWorkdir) {
2854
3063
  },
2855
3064
  { lineWidth: 0 }
2856
3065
  );
2857
- writeFileSync9(
3066
+ writeFileSync10(
2858
3067
  sessionYamlPath(trimmedId, apmRoot),
2859
3068
  sessionYaml.endsWith("\n") ? sessionYaml : `${sessionYaml}
2860
3069
  `,
2861
3070
  "utf8"
2862
3071
  );
2863
- writeFileSync9(
3072
+ writeFileSync10(
2864
3073
  sessionMessagesXmlPath(trimmedId, apmRoot),
2865
3074
  formatSessionMessagesXml(trimmedId, messages),
2866
3075
  "utf8"
@@ -2877,15 +3086,15 @@ async function runPull(sessionId, remoteWorkdir) {
2877
3086
  import { spawnSync } from "child_process";
2878
3087
 
2879
3088
  // src/version.ts
2880
- import { readFileSync as readFileSync7 } from "fs";
2881
- import { dirname as dirname3, join as join10 } from "path";
3089
+ import { readFileSync as readFileSync8 } from "fs";
3090
+ import { dirname as dirname4, join as join11 } from "path";
2882
3091
  import { fileURLToPath as fileURLToPath2 } from "url";
2883
3092
  var CLI_PACKAGE_NAME = "ai-project-manage-cli";
2884
3093
  function readCliVersion() {
2885
3094
  try {
2886
- const dir = dirname3(fileURLToPath2(import.meta.url));
2887
- const pkgPath = join10(dir, "..", "package.json");
2888
- const pkg = JSON.parse(readFileSync7(pkgPath, "utf8"));
3095
+ const dir = dirname4(fileURLToPath2(import.meta.url));
3096
+ const pkgPath = join11(dir, "..", "package.json");
3097
+ const pkg = JSON.parse(readFileSync8(pkgPath, "utf8"));
2889
3098
  return pkg.version ?? "0.0.0";
2890
3099
  } catch {
2891
3100
  return "0.0.0";
@@ -3039,15 +3248,15 @@ async function runUpdate(options = {}) {
3039
3248
 
3040
3249
  // src/commands/update-skills.ts
3041
3250
  init_client();
3042
- import { existsSync as existsSync7, mkdirSync as mkdirSync4, statSync as statSync3 } from "fs";
3043
- import { join as join11 } from "path";
3251
+ import { existsSync as existsSync8, mkdirSync as mkdirSync5, statSync as statSync4 } from "fs";
3252
+ import { join as join12 } from "path";
3044
3253
  async function syncWorkspaceSkills(cfg, workdir) {
3045
3254
  const apmDir = workspaceApmDir(workdir);
3046
3255
  const fsApmDir = toFsPath(apmDir);
3047
- if (!existsSync7(fsApmDir)) {
3256
+ if (!existsSync8(fsApmDir)) {
3048
3257
  throw new Error("[apm] \u672A\u627E\u5230 .apm \u76EE\u5F55\uFF0C\u8BF7\u5148\u6267\u884C apm init");
3049
3258
  }
3050
- const apmStat = statSync3(fsApmDir);
3259
+ const apmStat = statSync4(fsApmDir);
3051
3260
  if (!apmStat.isDirectory()) {
3052
3261
  throw new Error(`[apm] \u8DEF\u5F84\u5DF2\u5B58\u5728\u4F46\u4E0D\u662F\u76EE\u5F55: ${apmDir}`);
3053
3262
  }
@@ -3056,13 +3265,13 @@ async function syncWorkspaceSkills(cfg, workdir) {
3056
3265
  if (syncAgentsGuide(apmDir)) {
3057
3266
  console.log("[apm] \u5DF2\u540C\u6B65 APM \u6307\u5357: .apm/AGENTS.md");
3058
3267
  }
3059
- const rulesDir = join11(apmDir, "rules");
3268
+ const rulesDir = join12(apmDir, "rules");
3060
3269
  const ruleNames = syncBaseRules(rulesDir);
3061
3270
  for (const name of ruleNames) {
3062
3271
  console.log(`[apm] \u5DF2\u540C\u6B65\u57FA\u7840\u89C4\u5219: rules/${name}`);
3063
3272
  }
3064
- const skillsDir = join11(apmDir, "skills");
3065
- mkdirSync4(toFsPath(skillsDir), { recursive: true });
3273
+ const skillsDir = join12(apmDir, "skills");
3274
+ mkdirSync5(toFsPath(skillsDir), { recursive: true });
3066
3275
  const baseNames = syncBaseSkills(skillsDir);
3067
3276
  for (const name of baseNames) {
3068
3277
  console.log(`[apm] \u5DF2\u540C\u6B65\u57FA\u7840\u6280\u80FD: skills/${name}/`);
@@ -3088,11 +3297,11 @@ async function syncWorkspaceSkills(cfg, workdir) {
3088
3297
  }
3089
3298
  async function runUpdateSkills() {
3090
3299
  const apmDir = workspaceApmDir();
3091
- if (!existsSync7(apmDir)) {
3300
+ if (!existsSync8(apmDir)) {
3092
3301
  console.error("[apm] \u672A\u627E\u5230 .apm \u76EE\u5F55\uFF0C\u8BF7\u5148\u6267\u884C apm init");
3093
3302
  process.exit(1);
3094
3303
  }
3095
- const apmStat = statSync3(apmDir);
3304
+ const apmStat = statSync4(apmDir);
3096
3305
  if (!apmStat.isDirectory()) {
3097
3306
  throw new Error(`[apm] \u8DEF\u5F84\u5DF2\u5B58\u5728\u4F46\u4E0D\u662F\u76EE\u5F55: ${apmDir}`);
3098
3307
  }
@@ -3101,15 +3310,15 @@ async function runUpdateSkills() {
3101
3310
  }
3102
3311
 
3103
3312
  // src/commands/sync-deploy-config.ts
3104
- import { existsSync as existsSync8, statSync as statSync4 } from "fs";
3313
+ import { existsSync as existsSync9, statSync as statSync5 } from "fs";
3105
3314
  async function runSyncDeployConfig() {
3106
3315
  const workdir = resolveWorkdirPath();
3107
3316
  const apmDir = workspaceApmDir(workdir);
3108
- if (!existsSync8(apmDir)) {
3317
+ if (!existsSync9(apmDir)) {
3109
3318
  console.error("[apm] \u672A\u627E\u5230 .apm \u76EE\u5F55\uFF0C\u8BF7\u5148\u6267\u884C apm init");
3110
3319
  process.exit(1);
3111
3320
  }
3112
- const apmStat = statSync4(apmDir);
3321
+ const apmStat = statSync5(apmDir);
3113
3322
  if (!apmStat.isDirectory()) {
3114
3323
  throw new Error(`[apm] \u8DEF\u5F84\u5DF2\u5B58\u5728\u4F46\u4E0D\u662F\u76EE\u5F55: ${apmDir}`);
3115
3324
  }
@@ -3140,8 +3349,8 @@ async function runSyncProjectDocuments(options) {
3140
3349
  }
3141
3350
 
3142
3351
  // src/commands/sync-document.ts
3143
- import { existsSync as existsSync10, readFileSync as readFileSync9 } from "fs";
3144
- import { basename as basename3 } from "path";
3352
+ import { existsSync as existsSync11, readFileSync as readFileSync10 } from "fs";
3353
+ import { basename as basename4 } from "path";
3145
3354
 
3146
3355
  // src/assumptions/local-validate.ts
3147
3356
  var NO_ASSUMPTIONS_RE = /无[,,]?\s*口径均有依据/;
@@ -3311,13 +3520,13 @@ init_client();
3311
3520
 
3312
3521
  // src/commands/sync-session-documents.ts
3313
3522
  init_client();
3314
- import { existsSync as existsSync9, readdirSync as readdirSync4, readFileSync as readFileSync8 } from "fs";
3315
- import { join as join12 } from "path";
3523
+ import { existsSync as existsSync10, readdirSync as readdirSync5, readFileSync as readFileSync9 } from "fs";
3524
+ import { join as join13 } from "path";
3316
3525
  function listLocalMarkdownFiles(docsDir) {
3317
- if (!existsSync9(docsDir)) {
3526
+ if (!existsSync10(docsDir)) {
3318
3527
  return [];
3319
3528
  }
3320
- return readdirSync4(docsDir).filter(
3529
+ return readdirSync5(docsDir).filter(
3321
3530
  (name) => name.toLowerCase().endsWith(".md")
3322
3531
  );
3323
3532
  }
@@ -3329,8 +3538,8 @@ function remoteDocumentByLocalName(remoteDocuments, localFileName) {
3329
3538
  });
3330
3539
  }
3331
3540
  async function upsertLocalDocumentFile(api, sessionId, docsDir, fileName) {
3332
- const absPath = join12(docsDir, fileName);
3333
- const content = readFileSync8(absPath, "utf8");
3541
+ const absPath = join13(docsDir, fileName);
3542
+ const content = readFileSync9(absPath, "utf8");
3334
3543
  const name = documentPlatformName(absPath);
3335
3544
  return api.cli.upsertDocument({
3336
3545
  sessionId,
@@ -3352,8 +3561,8 @@ async function syncSessionDocuments(cfg, sessionId, apmRoot, options) {
3352
3561
  const remoteDocuments = options?.remoteDocuments ?? await api.cli.listDocuments({ sessionId: trimmedSessionId });
3353
3562
  let synced = 0;
3354
3563
  for (const fileName of localFiles) {
3355
- const absPath = join12(docsDir, fileName);
3356
- const content = readFileSync8(absPath, "utf8");
3564
+ const absPath = join13(docsDir, fileName);
3565
+ const content = readFileSync9(absPath, "utf8");
3357
3566
  const remote = remoteDocumentByLocalName(remoteDocuments, fileName);
3358
3567
  if (remote && remote.content === content) {
3359
3568
  continue;
@@ -3386,7 +3595,7 @@ async function runSyncDocument(sessionId, options) {
3386
3595
  process.exit(1);
3387
3596
  }
3388
3597
  const absPath = resolveSessionDocumentPath(trimmedSessionId, fileArg);
3389
- if (!existsSync10(absPath)) {
3598
+ if (!existsSync11(absPath)) {
3390
3599
  const docsDir2 = sessionDocsDir(trimmedSessionId);
3391
3600
  console.error(
3392
3601
  `[apm] \u6587\u6863\u4E0D\u5B58\u5728: ${absPath}
@@ -3394,10 +3603,10 @@ async function runSyncDocument(sessionId, options) {
3394
3603
  );
3395
3604
  process.exit(1);
3396
3605
  }
3397
- const fileName = basename3(absPath);
3606
+ const fileName = basename4(absPath);
3398
3607
  const assumptionSource = resolveAssumptionSourceFromFileName(fileName);
3399
3608
  if (assumptionSource) {
3400
- const content = readFileSync9(absPath, "utf8");
3609
+ const content = readFileSync10(absPath, "utf8");
3401
3610
  const validation = validateAssumptionsMarkdown(content, assumptionSource);
3402
3611
  if (!validation.ok) {
3403
3612
  printAssumptionValidationResult(validation);
@@ -3414,7 +3623,7 @@ async function runSyncDocument(sessionId, options) {
3414
3623
  api,
3415
3624
  trimmedSessionId,
3416
3625
  docsDir,
3417
- basename3(absPath)
3626
+ basename4(absPath)
3418
3627
  );
3419
3628
  console.log(`[apm] \u5DF2\u540C\u6B65\u6587\u6863: ${doc.name} (id=${doc.id})`);
3420
3629
  const assumptionSync = doc.assumptionSync;
@@ -3759,8 +3968,8 @@ init_client();
3759
3968
  import path11 from "node:path";
3760
3969
 
3761
3970
  // src/commands/deploy/internal/apm-config.ts
3762
- import { existsSync as existsSync12, readFileSync as readFileSync11 } from "node:fs";
3763
- import { resolve as resolve4 } from "node:path";
3971
+ import { existsSync as existsSync13, readFileSync as readFileSync12 } from "node:fs";
3972
+ import { resolve as resolve5 } from "node:path";
3764
3973
 
3765
3974
  // src/commands/deploy/internal/config/config-validation.ts
3766
3975
  function req(v, field, section) {
@@ -3852,9 +4061,9 @@ function resolveFrontendDeployFromApmConfig(cfg) {
3852
4061
  }
3853
4062
 
3854
4063
  // src/commands/deploy/internal/config/maven-repo.ts
3855
- import { existsSync as existsSync11, readFileSync as readFileSync10 } from "node:fs";
4064
+ import { existsSync as existsSync12, readFileSync as readFileSync11 } from "node:fs";
3856
4065
  import { homedir as homedir2 } from "node:os";
3857
- import { join as join13, resolve as resolve3 } from "node:path";
4066
+ import { join as join14, resolve as resolve4 } from "node:path";
3858
4067
  var MAVEN_REPO_ENV_KEYS = [
3859
4068
  "MAVEN_LOCAL_REPO",
3860
4069
  "M2_REPO",
@@ -3887,7 +4096,7 @@ function expandUserPath(pathStr, env = process.env) {
3887
4096
  if (/^[a-zA-Z]:[/\\]/.test(expanded)) {
3888
4097
  return expanded;
3889
4098
  }
3890
- return resolve3(expanded);
4099
+ return resolve4(expanded);
3891
4100
  }
3892
4101
  function readMavenLocalRepoFromMavenOpts(mavenOpts, env = process.env) {
3893
4102
  const match = mavenOpts.match(/-Dmaven\.repo\.local=(?:"([^"]+)"|(\S+))/);
@@ -3911,12 +4120,12 @@ function readMavenLocalRepoFromEnv(env = process.env) {
3911
4120
  return null;
3912
4121
  }
3913
4122
  function readMavenLocalRepoFromSettings() {
3914
- const settingsPath = join13(homedir2(), ".m2", "settings.xml");
3915
- if (!existsSync11(settingsPath)) {
4123
+ const settingsPath = join14(homedir2(), ".m2", "settings.xml");
4124
+ if (!existsSync12(settingsPath)) {
3916
4125
  return null;
3917
4126
  }
3918
4127
  try {
3919
- const xml = readFileSync10(settingsPath, "utf8");
4128
+ const xml = readFileSync11(settingsPath, "utf8");
3920
4129
  const match = xml.match(
3921
4130
  /<localRepository>\s*([^<]+?)\s*<\/localRepository>/
3922
4131
  );
@@ -3947,7 +4156,7 @@ function resolveMavenLocalRepoWithSource() {
3947
4156
  };
3948
4157
  }
3949
4158
  return {
3950
- path: join13(homedir2(), ".m2", "repository"),
4159
+ path: join14(homedir2(), ".m2", "repository"),
3951
4160
  source: "default",
3952
4161
  sourceDetail: "~/.m2/repository"
3953
4162
  };
@@ -4043,16 +4252,16 @@ function resolveWisdomBackendDeployFromApmConfig(cfg) {
4043
4252
 
4044
4253
  // src/commands/deploy/internal/apm-config.ts
4045
4254
  function loadApmConfig(options) {
4046
- const p = resolve4(
4255
+ const p = resolve5(
4047
4256
  process.cwd(),
4048
- options?.configPath ?? resolve4(workspaceApmDir(), "apm.config.json")
4257
+ options?.configPath ?? resolve5(workspaceApmDir(), "apm.config.json")
4049
4258
  );
4050
- if (!existsSync12(p)) {
4259
+ if (!existsSync13(p)) {
4051
4260
  console.error(`\u672A\u627E\u5230\u914D\u7F6E\u6587\u4EF6\uFF1A${p}`);
4052
4261
  process.exit(1);
4053
4262
  }
4054
4263
  try {
4055
- const raw = readFileSync11(p, "utf8");
4264
+ const raw = readFileSync12(p, "utf8");
4056
4265
  return JSON.parse(raw);
4057
4266
  } catch (e) {
4058
4267
  console.error(`\u65E0\u6CD5\u89E3\u6790 apm.config.json\uFF1A${p}`, e);
@@ -4098,32 +4307,32 @@ var DeployExecutionError = class extends Error {
4098
4307
  // src/commands/deploy/deploy-debug-log.ts
4099
4308
  init_deploy_artifact_minio();
4100
4309
  import { spawnSync as spawnSync4 } from "node:child_process";
4101
- import { existsSync as existsSync16 } from "node:fs";
4102
- import { dirname as dirname5, join as join17 } from "node:path";
4310
+ import { existsSync as existsSync17 } from "node:fs";
4311
+ import { dirname as dirname6, join as join18 } from "node:path";
4103
4312
 
4104
4313
  // src/commands/deploy/internal/deploy-shell-env.ts
4105
4314
  import { spawnSync as spawnSync3 } from "node:child_process";
4106
- import { existsSync as existsSync15 } from "node:fs";
4107
- import { dirname as dirname4, join as join16 } from "node:path";
4315
+ import { existsSync as existsSync16 } from "node:fs";
4316
+ import { dirname as dirname5, join as join17 } from "node:path";
4108
4317
 
4109
4318
  // src/commands/daemon.ts
4110
4319
  init_config();
4111
4320
  import { spawnSync as spawnSync2 } from "child_process";
4112
4321
  import { setTimeout as delay } from "node:timers/promises";
4113
- import { existsSync as existsSync14, mkdirSync as mkdirSync6, unlinkSync as unlinkSync2, writeFileSync as writeFileSync11 } from "fs";
4114
- import { join as join15 } from "path";
4322
+ import { existsSync as existsSync15, mkdirSync as mkdirSync7, unlinkSync as unlinkSync2, writeFileSync as writeFileSync12 } from "fs";
4323
+ import { join as join16 } from "path";
4115
4324
 
4116
4325
  // src/commands/connect-lock.ts
4117
4326
  init_config();
4118
4327
  import {
4119
- existsSync as existsSync13,
4120
- mkdirSync as mkdirSync5,
4121
- readFileSync as readFileSync12,
4328
+ existsSync as existsSync14,
4329
+ mkdirSync as mkdirSync6,
4330
+ readFileSync as readFileSync13,
4122
4331
  unlinkSync,
4123
- writeFileSync as writeFileSync10
4332
+ writeFileSync as writeFileSync11
4124
4333
  } from "fs";
4125
- import { join as join14 } from "path";
4126
- var CONNECT_LOCK_PATH = join14(APM_CONFIG_DIR, "connect.lock");
4334
+ import { join as join15 } from "path";
4335
+ var CONNECT_LOCK_PATH = join15(APM_CONFIG_DIR, "connect.lock");
4127
4336
  function isProcessAlive(pid) {
4128
4337
  if (!Number.isInteger(pid) || pid <= 0) return false;
4129
4338
  try {
@@ -4150,9 +4359,9 @@ function waitForPm2LockHandoff(timeoutMs = 5e3) {
4150
4359
  }
4151
4360
  }
4152
4361
  function readConnectLock() {
4153
- if (!existsSync13(CONNECT_LOCK_PATH)) return null;
4362
+ if (!existsSync14(CONNECT_LOCK_PATH)) return null;
4154
4363
  try {
4155
- const raw = readFileSync12(CONNECT_LOCK_PATH, "utf8");
4364
+ const raw = readFileSync13(CONNECT_LOCK_PATH, "utf8");
4156
4365
  const parsed = JSON.parse(raw);
4157
4366
  if (typeof parsed.pid !== "number" || parsed.mode !== "foreground" && parsed.mode !== "pm2" || typeof parsed.startedAt !== "string") {
4158
4367
  return null;
@@ -4187,13 +4396,13 @@ function acquireConnectLock(mode) {
4187
4396
  process.exit(1);
4188
4397
  }
4189
4398
  }
4190
- mkdirSync5(APM_CONFIG_DIR, { recursive: true });
4399
+ mkdirSync6(APM_CONFIG_DIR, { recursive: true });
4191
4400
  const lock = {
4192
4401
  pid: process.pid,
4193
4402
  mode,
4194
4403
  startedAt: (/* @__PURE__ */ new Date()).toISOString()
4195
4404
  };
4196
- writeFileSync10(
4405
+ writeFileSync11(
4197
4406
  CONNECT_LOCK_PATH,
4198
4407
  JSON.stringify(lock, null, 2) + "\n",
4199
4408
  "utf8"
@@ -4209,7 +4418,7 @@ function releaseConnectLock() {
4209
4418
  }
4210
4419
  function forceReleaseConnectLock() {
4211
4420
  try {
4212
- if (existsSync13(CONNECT_LOCK_PATH)) {
4421
+ if (existsSync14(CONNECT_LOCK_PATH)) {
4213
4422
  unlinkSync(CONNECT_LOCK_PATH);
4214
4423
  }
4215
4424
  } catch {
@@ -4218,16 +4427,16 @@ function forceReleaseConnectLock() {
4218
4427
 
4219
4428
  // src/commands/daemon.ts
4220
4429
  var PM2_APP_NAME = "apm-connect";
4221
- var PM2_ECOSYSTEM_PATH = join15(
4430
+ var PM2_ECOSYSTEM_PATH = join16(
4222
4431
  APM_CONFIG_DIR,
4223
4432
  "connect.ecosystem.config.cjs"
4224
4433
  );
4225
- var PM2_CONNECT_ENTRY_PATH = join15(APM_CONFIG_DIR, "connect.entry.cjs");
4226
- var PM2_CONNECT_LAUNCH_PATH = join15(
4434
+ var PM2_CONNECT_ENTRY_PATH = join16(APM_CONFIG_DIR, "connect.entry.cjs");
4435
+ var PM2_CONNECT_LAUNCH_PATH = join16(
4227
4436
  APM_CONFIG_DIR,
4228
4437
  "connect.launch.json"
4229
4438
  );
4230
- var LEGACY_PM2_ECOSYSTEM_PATH = join15(
4439
+ var LEGACY_PM2_ECOSYSTEM_PATH = join16(
4231
4440
  APM_CONFIG_DIR,
4232
4441
  "connect.ecosystem.cjs"
4233
4442
  );
@@ -4358,8 +4567,8 @@ function resolvePm2FromNpmRoot() {
4358
4567
  const root = rootResult.stdout?.toString().trim();
4359
4568
  if (!root) return null;
4360
4569
  for (const rel of ["pm2/bin/pm2", "pm2/bin/pm2.js"]) {
4361
- const candidate = join15(root, ...rel.split("/"));
4362
- if (existsSync14(candidate)) {
4570
+ const candidate = join16(root, ...rel.split("/"));
4571
+ if (existsSync15(candidate)) {
4363
4572
  return candidate;
4364
4573
  }
4365
4574
  }
@@ -4396,7 +4605,7 @@ function spawnPm2At(binPath, args, options = {}) {
4396
4605
  return spawnPm2Target(buildPm2SpawnTarget(binPath), args, options);
4397
4606
  }
4398
4607
  function verifyPm2Bin(pm2Bin) {
4399
- if (!pm2Bin.trim() || !existsSync14(pm2Bin)) {
4608
+ if (!pm2Bin.trim() || !existsSync15(pm2Bin)) {
4400
4609
  return false;
4401
4610
  }
4402
4611
  const result = spawnPm2At(pm2Bin, ["--version"], {
@@ -4409,10 +4618,10 @@ function collectPm2Candidates() {
4409
4618
  const globalBin = resolveNpmGlobalBin();
4410
4619
  if (globalBin) {
4411
4620
  if (useNpmShell2) {
4412
- candidates.push(join15(globalBin, "pm2.cmd"));
4413
- candidates.push(join15(globalBin, "pm2"));
4621
+ candidates.push(join16(globalBin, "pm2.cmd"));
4622
+ candidates.push(join16(globalBin, "pm2"));
4414
4623
  } else {
4415
- candidates.push(join15(globalBin, "pm2"));
4624
+ candidates.push(join16(globalBin, "pm2"));
4416
4625
  }
4417
4626
  }
4418
4627
  const fromRoot = resolvePm2FromNpmRoot();
@@ -4535,7 +4744,7 @@ function ensureGlobalPm2(options) {
4535
4744
  }
4536
4745
  function resolveApmEntryPath(entryArg = process.argv[1]) {
4537
4746
  const fromArgv = entryArg?.trim();
4538
- if (fromArgv && existsSync14(fromArgv)) {
4747
+ if (fromArgv && existsSync15(fromArgv)) {
4539
4748
  return fromArgv;
4540
4749
  }
4541
4750
  const npmResult = spawnSync2(useNpmShell2 ? "npm.cmd" : "npm", ["root", "-g"], {
@@ -4546,8 +4755,8 @@ function resolveApmEntryPath(entryArg = process.argv[1]) {
4546
4755
  if (npmResult.status === 0) {
4547
4756
  const globalRoot = npmResult.stdout?.toString().trim();
4548
4757
  if (globalRoot) {
4549
- const candidate = join15(globalRoot, CLI_PACKAGE_NAME, "dist", "index.js");
4550
- if (existsSync14(candidate)) {
4758
+ const candidate = join16(globalRoot, CLI_PACKAGE_NAME, "dist", "index.js");
4759
+ if (existsSync15(candidate)) {
4551
4760
  return candidate;
4552
4761
  }
4553
4762
  }
@@ -4705,8 +4914,8 @@ async function resolveBaseUrl(server) {
4705
4914
  return cfg?.baseUrl;
4706
4915
  }
4707
4916
  function writeConnectLaunchFiles(options) {
4708
- mkdirSync6(APM_CONFIG_DIR, { recursive: true });
4709
- writeFileSync11(PM2_CONNECT_ENTRY_PATH, CONNECT_ENTRY_SCRIPT, "utf8");
4917
+ mkdirSync7(APM_CONFIG_DIR, { recursive: true });
4918
+ writeFileSync12(PM2_CONNECT_ENTRY_PATH, CONNECT_ENTRY_SCRIPT, "utf8");
4710
4919
  const env = {
4711
4920
  ...collectPm2LaunchEnv()
4712
4921
  };
@@ -4721,7 +4930,7 @@ function writeConnectLaunchFiles(options) {
4721
4930
  cwd: options.cwd,
4722
4931
  env
4723
4932
  };
4724
- writeFileSync11(
4933
+ writeFileSync12(
4725
4934
  PM2_CONNECT_LAUNCH_PATH,
4726
4935
  JSON.stringify(launch, null, 2) + "\n",
4727
4936
  "utf8"
@@ -4733,12 +4942,12 @@ function writeEcosystemFile(options) {
4733
4942
  entryScript: PM2_CONNECT_ENTRY_PATH,
4734
4943
  baseUrl: options.baseUrl
4735
4944
  });
4736
- writeFileSync11(
4945
+ writeFileSync12(
4737
4946
  PM2_ECOSYSTEM_PATH,
4738
4947
  formatConnectPm2EcosystemFile(ecosystem),
4739
4948
  "utf8"
4740
4949
  );
4741
- if (existsSync14(LEGACY_PM2_ECOSYSTEM_PATH)) {
4950
+ if (existsSync15(LEGACY_PM2_ECOSYSTEM_PATH)) {
4742
4951
  try {
4743
4952
  unlinkSync2(LEGACY_PM2_ECOSYSTEM_PATH);
4744
4953
  } catch {
@@ -4897,14 +5106,14 @@ function writeEnvPath(env, value) {
4897
5106
  env.PATH = value;
4898
5107
  }
4899
5108
  function resolveNodeInstallDir() {
4900
- return dirname4(process.execPath);
5109
+ return dirname5(process.execPath);
4901
5110
  }
4902
5111
  function resolveNpmCmdPath() {
4903
5112
  if (process.platform !== "win32") {
4904
5113
  return null;
4905
5114
  }
4906
- const candidate = join16(resolveNodeInstallDir(), "npm.cmd");
4907
- return existsSync15(candidate) ? candidate : null;
5115
+ const candidate = join17(resolveNodeInstallDir(), "npm.cmd");
5116
+ return existsSync16(candidate) ? candidate : null;
4908
5117
  }
4909
5118
  function formatNpmRunShellCommand(scriptName) {
4910
5119
  const trimmed = scriptName.trim();
@@ -5076,7 +5285,7 @@ function logExecuteDeployContext(input) {
5076
5285
  const deploymentRunId = process.env[APM_DEPLOYMENT_RUN_ID_ENV]?.trim() || null;
5077
5286
  const shellEnv = buildDeployShellEnv();
5078
5287
  const npmGlobalBin = resolveNpmGlobalBin2();
5079
- const packageJsonPath = join17(input.cwd, "package.json");
5288
+ const packageJsonPath = join18(input.cwd, "package.json");
5080
5289
  logLine("========== executeDeploy \u4E0A\u4E0B\u6587 ==========");
5081
5290
  logLine(`trigger=${trigger} deployEnv=${input.env}`);
5082
5291
  logLine(`cwd(input)=${input.cwdInput}`);
@@ -5086,12 +5295,12 @@ function logExecuteDeployContext(input) {
5086
5295
  `cwdMatchProcess=${input.cwd === input.processCwd ? "yes" : "no"} (connect \u901A\u5E38\u4E3A no)`
5087
5296
  );
5088
5297
  logLine(
5089
- `apm.config=${input.apmConfigPath} exists=${existsSync16(
5298
+ `apm.config=${input.apmConfigPath} exists=${existsSync17(
5090
5299
  input.apmConfigPath
5091
5300
  )}`
5092
5301
  );
5093
5302
  logLine(
5094
- `package.json=${packageJsonPath} exists=${existsSync16(packageJsonPath)}`
5303
+ `package.json=${packageJsonPath} exists=${existsSync17(packageJsonPath)}`
5095
5304
  );
5096
5305
  logLine(
5097
5306
  `flags captureOutput=${input.captureOutput} packOnly=${Boolean(
@@ -5105,7 +5314,7 @@ function logExecuteDeployContext(input) {
5105
5314
  );
5106
5315
  logLine(`process argv=${process.argv.join(" ")}`);
5107
5316
  logLine(`npmGlobalBin=${npmGlobalBin ?? "(resolve failed)"}`);
5108
- logLine(`nodeDir=${dirname5(process.execPath)}`);
5317
+ logLine(`nodeDir=${dirname6(process.execPath)}`);
5109
5318
  logLine("--- process.env\uFF08\u8282\u9009\uFF09---");
5110
5319
  for (const [key, value] of Object.entries(
5111
5320
  collectInterestingEnv(process.env)
@@ -5147,14 +5356,14 @@ function logWisdomFrontendDeployContext(input) {
5147
5356
  logLine(
5148
5357
  `buildKey=build:${input.env} buildCmd=${input.buildCmd ?? "(missing)"}`
5149
5358
  );
5150
- logLine(`distDir=${input.distDir} exists=${existsSync16(input.distDir)}`);
5359
+ logLine(`distDir=${input.distDir} exists=${existsSync17(input.distDir)}`);
5151
5360
  logLine(
5152
5361
  `packOnly=${input.packOnly} archiveDeployArtifact=${input.archiveDeployArtifact}`
5153
5362
  );
5154
5363
  }
5155
5364
 
5156
5365
  // src/commands/deploy/internal/wisdom-deploy.ts
5157
- import { existsSync as existsSync20, readFileSync as readFileSync15, statSync as statSync9 } from "node:fs";
5366
+ import { existsSync as existsSync21, readFileSync as readFileSync16, statSync as statSync10 } from "node:fs";
5158
5367
  import path10 from "node:path";
5159
5368
 
5160
5369
  // src/commands/deploy/deploy-shell-run.ts
@@ -5253,22 +5462,22 @@ init_deploy_artifact_minio();
5253
5462
 
5254
5463
  // src/commands/deploy/internal/wisdom-backend/jar-incremental.ts
5255
5464
  import {
5256
- mkdirSync as mkdirSync8,
5257
- readdirSync as readdirSync5,
5258
- readFileSync as readFileSync14,
5259
- statSync as statSync7,
5260
- writeFileSync as writeFileSync13
5465
+ mkdirSync as mkdirSync9,
5466
+ readdirSync as readdirSync6,
5467
+ readFileSync as readFileSync15,
5468
+ statSync as statSync8,
5469
+ writeFileSync as writeFileSync14
5261
5470
  } from "node:fs";
5262
5471
  import path6 from "node:path";
5263
5472
  import JSZip2 from "jszip";
5264
5473
 
5265
5474
  // src/commands/deploy/internal/wisdom-backend/manifest.ts
5266
5475
  import {
5267
- existsSync as existsSync17,
5268
- mkdirSync as mkdirSync7,
5269
- readFileSync as readFileSync13,
5270
- statSync as statSync6,
5271
- writeFileSync as writeFileSync12
5476
+ existsSync as existsSync18,
5477
+ mkdirSync as mkdirSync8,
5478
+ readFileSync as readFileSync14,
5479
+ statSync as statSync7,
5480
+ writeFileSync as writeFileSync13
5272
5481
  } from "node:fs";
5273
5482
  import path2 from "node:path";
5274
5483
  function deployCacheDir() {
@@ -5281,20 +5490,20 @@ function relativeKey(projectRoot, filePath) {
5281
5490
  return path2.relative(projectRoot, filePath).split(path2.sep).join("/");
5282
5491
  }
5283
5492
  function fileSignature(filePath) {
5284
- const stat2 = statSync6(filePath);
5493
+ const stat2 = statSync7(filePath);
5285
5494
  return { size: stat2.size, mtime: stat2.mtimeMs / 1e3 };
5286
5495
  }
5287
5496
  function loadManifest3() {
5288
- const manifestPath2 = manifestFilePath();
5289
- if (!existsSync17(manifestPath2)) {
5497
+ const manifestPath3 = manifestFilePath();
5498
+ if (!existsSync18(manifestPath3)) {
5290
5499
  return {};
5291
5500
  }
5292
- return JSON.parse(readFileSync13(manifestPath2, "utf8"));
5501
+ return JSON.parse(readFileSync14(manifestPath3, "utf8"));
5293
5502
  }
5294
5503
  function saveManifest3(manifest) {
5295
5504
  const dir = deployCacheDir();
5296
- mkdirSync7(dir, { recursive: true });
5297
- writeFileSync12(manifestFilePath(), JSON.stringify(manifest, null, 2), "utf8");
5505
+ mkdirSync8(dir, { recursive: true });
5506
+ writeFileSync13(manifestFilePath(), JSON.stringify(manifest, null, 2), "utf8");
5298
5507
  }
5299
5508
  function updateManifestEntries(manifest, entries, projectRoot) {
5300
5509
  for (const entry of entries) {
@@ -5427,7 +5636,7 @@ function buildSftpConnectOptions(settings) {
5427
5636
  };
5428
5637
  }
5429
5638
  async function sleep(ms) {
5430
- await new Promise((resolve7) => setTimeout(resolve7, ms));
5639
+ await new Promise((resolve8) => setTimeout(resolve8, ms));
5431
5640
  }
5432
5641
  async function uploadZipWithRetry(settings, localZip, remoteZipPath) {
5433
5642
  let lastError;
@@ -5471,7 +5680,7 @@ async function ensureRemoteDir(sftp, dir) {
5471
5680
  }
5472
5681
  }
5473
5682
  function execCommand(client, command) {
5474
- return new Promise((resolve7, reject) => {
5683
+ return new Promise((resolve8, reject) => {
5475
5684
  client.exec(command, (err, stream) => {
5476
5685
  if (err) return reject(err);
5477
5686
  let stdout = "";
@@ -5481,7 +5690,7 @@ function execCommand(client, command) {
5481
5690
  reject(new Error(`\u8FDC\u7A0B\u547D\u4EE4\u5931\u8D25 (${code}): ${stderr || stdout}`));
5482
5691
  return;
5483
5692
  }
5484
- resolve7(stdout);
5693
+ resolve8(stdout);
5485
5694
  }).on("data", (data) => {
5486
5695
  stdout += data.toString();
5487
5696
  });
@@ -5664,7 +5873,7 @@ function shouldUploadLibFile(localPath, remoteAttr, manifest, projectRoot) {
5664
5873
  if (!remoteAttr) {
5665
5874
  return [false, "\u8FDC\u7A0B\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7"];
5666
5875
  }
5667
- const localSize = statSync7(localPath).size;
5876
+ const localSize = statSync8(localPath).size;
5668
5877
  const remoteSize = remoteAttr.size;
5669
5878
  if (localSize !== remoteSize) {
5670
5879
  return [true, `\u5927\u5C0F\u53D8\u5316 ${remoteSize} -> ${localSize}`];
@@ -5687,7 +5896,7 @@ function shouldUploadLibFile(localPath, remoteAttr, manifest, projectRoot) {
5687
5896
  }
5688
5897
  function listLibFilesToUpload(localLibDir, remoteStats, projectRoot, manifest = null) {
5689
5898
  const entries = [];
5690
- const jarFiles = readdirSync5(localLibDir).filter((name) => name.endsWith(".jar")).sort();
5899
+ const jarFiles = readdirSync6(localLibDir).filter((name) => name.endsWith(".jar")).sort();
5691
5900
  for (const jarName of jarFiles) {
5692
5901
  const jarPath = path6.join(localLibDir, jarName);
5693
5902
  const remoteAttr = remoteStats.get(jarName);
@@ -5705,12 +5914,12 @@ function listLibFilesToUpload(localLibDir, remoteStats, projectRoot, manifest =
5705
5914
  }
5706
5915
  async function createUpdatePackage(entries, packageName) {
5707
5916
  const dir = deployCacheDirectory();
5708
- mkdirSync8(dir, { recursive: true });
5917
+ mkdirSync9(dir, { recursive: true });
5709
5918
  const zipPath = path6.join(dir, packageName);
5710
5919
  log(`\u521B\u5EFA\u66F4\u65B0\u5305: ${path6.basename(zipPath)}\uFF08${entries.length} \u4E2A\u6587\u4EF6\uFF09`);
5711
5920
  const zip = new JSZip2();
5712
5921
  for (const entry of entries) {
5713
- const content = readFileSync14(entry.path);
5922
+ const content = readFileSync15(entry.path);
5714
5923
  zip.file(entry.arcname, content);
5715
5924
  log(` \u6253\u5305: ${entry.arcname} (${entry.reason})`);
5716
5925
  }
@@ -5719,11 +5928,11 @@ async function createUpdatePackage(entries, packageName) {
5719
5928
  compression: "DEFLATE",
5720
5929
  compressionOptions: { level: 6 }
5721
5930
  });
5722
- writeFileSync13(zipPath, buffer);
5931
+ writeFileSync14(zipPath, buffer);
5723
5932
  return zipPath;
5724
5933
  }
5725
5934
  function listAllLibFilesForArchive(libDir) {
5726
- return readdirSync5(libDir).filter((name) => name.endsWith(".jar")).sort().map((jarName) => ({
5935
+ return readdirSync6(libDir).filter((name) => name.endsWith(".jar")).sort().map((jarName) => ({
5727
5936
  path: path6.join(libDir, jarName),
5728
5937
  arcname: jarName,
5729
5938
  reason: "\u4EC5\u6253\u5305\u5F52\u6863"
@@ -5731,7 +5940,7 @@ function listAllLibFilesForArchive(libDir) {
5731
5940
  }
5732
5941
 
5733
5942
  // src/commands/deploy/internal/wisdom-backend/maven-build.ts
5734
- import { existsSync as existsSync19, readdirSync as readdirSync6, statSync as statSync8 } from "node:fs";
5943
+ import { existsSync as existsSync20, readdirSync as readdirSync7, statSync as statSync9 } from "node:fs";
5735
5944
  import path7 from "node:path";
5736
5945
  import { spawnSync as spawnSync6 } from "node:child_process";
5737
5946
  function getMvnExecutable() {
@@ -5780,14 +5989,14 @@ function runMavenBuild(projectRoot, mavenLocalRepo, repoSource) {
5780
5989
  }
5781
5990
  function locateLibDir(projectRoot) {
5782
5991
  const targetDir = getTargetDir(projectRoot);
5783
- if (!existsSync19(targetDir)) {
5992
+ if (!existsSync20(targetDir)) {
5784
5993
  fail(`\u6784\u5EFA\u4EA7\u7269\u76EE\u5F55\u4E0D\u5B58\u5728: ${targetDir}`);
5785
5994
  }
5786
5995
  const libDir = path7.join(targetDir, "lib");
5787
- if (!existsSync19(libDir) || !statSync8(libDir).isDirectory()) {
5996
+ if (!existsSync20(libDir) || !statSync9(libDir).isDirectory()) {
5788
5997
  fail(`lib \u76EE\u5F55\u4E0D\u5B58\u5728: ${libDir}`);
5789
5998
  }
5790
- const libJars = readdirSync6(libDir).filter((name) => name.endsWith(".jar"));
5999
+ const libJars = readdirSync7(libDir).filter((name) => name.endsWith(".jar"));
5791
6000
  if (libJars.length === 0) {
5792
6001
  fail(`lib \u76EE\u5F55\u4E0B\u6CA1\u6709\u4F9D\u8D56 JAR: ${libDir}`);
5793
6002
  }
@@ -5796,10 +6005,10 @@ function locateLibDir(projectRoot) {
5796
6005
  }
5797
6006
  function locateMainJar(projectRoot) {
5798
6007
  const targetDir = getTargetDir(projectRoot);
5799
- if (!existsSync19(targetDir)) {
6008
+ if (!existsSync20(targetDir)) {
5800
6009
  fail(`\u6784\u5EFA\u4EA7\u7269\u76EE\u5F55\u4E0D\u5B58\u5728: ${targetDir}`);
5801
6010
  }
5802
- const jarFiles = readdirSync6(targetDir).filter((name) => name.endsWith(".jar") && !name.endsWith(".jar.original")).map((name) => path7.join(targetDir, name)).sort((a, b) => statSync8(b).mtimeMs - statSync8(a).mtimeMs);
6011
+ const jarFiles = readdirSync7(targetDir).filter((name) => name.endsWith(".jar") && !name.endsWith(".jar.original")).map((name) => path7.join(targetDir, name)).sort((a, b) => statSync9(b).mtimeMs - statSync9(a).mtimeMs);
5803
6012
  if (jarFiles.length === 0) {
5804
6013
  fail(`target \u76EE\u5F55\u4E0B\u6CA1\u6709\u4E3B JAR: ${targetDir}`);
5805
6014
  }
@@ -5956,8 +6165,8 @@ function springbootOutputIndicatesSuccess(action, combined) {
5956
6165
  async function connectSsh(config) {
5957
6166
  const client = new Client2();
5958
6167
  log(`\u8FDE\u63A5\u670D\u52A1\u5668 ${config.username}@${config.host}:${config.port}`);
5959
- await new Promise((resolve7, reject) => {
5960
- client.on("ready", () => resolve7()).on("error", (err) => reject(err)).connect({
6168
+ await new Promise((resolve8, reject) => {
6169
+ client.on("ready", () => resolve8()).on("error", (err) => reject(err)).connect({
5961
6170
  host: config.host,
5962
6171
  port: config.port,
5963
6172
  username: config.username,
@@ -6025,7 +6234,7 @@ async function runRemoteCommand(client, command, options) {
6025
6234
  const check = options?.check ?? true;
6026
6235
  const stream = options?.stream ?? false;
6027
6236
  const label = options?.label ?? "\u8FDC\u7A0B\u547D\u4EE4";
6028
- return new Promise((resolve7, reject) => {
6237
+ return new Promise((resolve8, reject) => {
6029
6238
  client.exec(command, (err, execStream) => {
6030
6239
  if (err) {
6031
6240
  reject(err);
@@ -6055,7 +6264,7 @@ ${errText}`.trim();
6055
6264
  \u8F93\u51FA: ${combined}` : "")
6056
6265
  );
6057
6266
  }
6058
- resolve7({ exitCode: code, out: out.trim(), err: errText.trim() });
6267
+ resolve8({ exitCode: code, out: out.trim(), err: errText.trim() });
6059
6268
  });
6060
6269
  });
6061
6270
  });
@@ -6285,15 +6494,15 @@ function isWisdomDeployConfigured(cfg) {
6285
6494
  return Boolean(w?.host?.trim() && w?.remotePath?.trim());
6286
6495
  }
6287
6496
  function detectWisdomProjectType(cwd) {
6288
- return existsSync20(path10.join(cwd, "package.json")) ? "frontend" : "backend";
6497
+ return existsSync21(path10.join(cwd, "package.json")) ? "frontend" : "backend";
6289
6498
  }
6290
6499
  function readPackageScripts(cwd) {
6291
6500
  const pkgPath = path10.join(cwd, "package.json");
6292
- if (!existsSync20(pkgPath)) {
6501
+ if (!existsSync21(pkgPath)) {
6293
6502
  return {};
6294
6503
  }
6295
6504
  try {
6296
- const raw = readFileSync15(pkgPath, "utf8");
6505
+ const raw = readFileSync16(pkgPath, "utf8");
6297
6506
  const parsed = JSON.parse(raw);
6298
6507
  return parsed.scripts ?? {};
6299
6508
  } catch {
@@ -6316,7 +6525,7 @@ function resolveFrontendDistDir(cwd) {
6316
6525
  for (const rel of candidates) {
6317
6526
  const full = path10.join(cwd, rel);
6318
6527
  try {
6319
- if (existsSync20(full) && statSync9(full).isDirectory()) {
6528
+ if (existsSync21(full) && statSync10(full).isDirectory()) {
6320
6529
  return full;
6321
6530
  }
6322
6531
  } catch {
@@ -6884,7 +7093,7 @@ async function handleInboundDeploy(cfg, msg, signal) {
6884
7093
  }
6885
7094
 
6886
7095
  // src/commands/clean-session-cache.ts
6887
- import { existsSync as existsSync21, rmSync as rmSync4 } from "node:fs";
7096
+ import { existsSync as existsSync22, rmSync as rmSync4 } from "node:fs";
6888
7097
 
6889
7098
  // src/commands/connect/pre-step-cache.ts
6890
7099
  var PULL_TTL_MS = 3e4;
@@ -6926,7 +7135,7 @@ function cleanSessionWorkspaceCache(sessionId, workdir) {
6926
7135
  return;
6927
7136
  }
6928
7137
  const dir = sessionDir(trimmedSessionId, workspaceApmDir(trimmedWorkdir));
6929
- if (existsSync21(dir)) {
7138
+ if (existsSync22(dir)) {
6930
7139
  rmSync4(dir, { recursive: true, force: true });
6931
7140
  console.log(`[apm] \u5DF2\u6E05\u7406\u4F1A\u8BDD\u7F13\u5B58 ${dir}`);
6932
7141
  } else {
@@ -6936,16 +7145,16 @@ function cleanSessionWorkspaceCache(sessionId, workdir) {
6936
7145
  }
6937
7146
 
6938
7147
  // src/commands/clean-webide-cache.ts
6939
- import { existsSync as existsSync22, rmSync as rmSync5 } from "node:fs";
6940
- import { resolve as resolve5 } from "node:path";
7148
+ import { existsSync as existsSync23, rmSync as rmSync5 } from "node:fs";
7149
+ import { resolve as resolve6 } from "node:path";
6941
7150
  function cleanWebIdeWorkspaceCache(taskId, workdir) {
6942
7151
  const trimmedTaskId = taskId.trim();
6943
7152
  const trimmedWorkdir = workdir.trim();
6944
7153
  if (!trimmedTaskId || !trimmedWorkdir) {
6945
7154
  return;
6946
7155
  }
6947
- const dir = resolve5(trimmedWorkdir, ".apm", "webide", trimmedTaskId);
6948
- if (existsSync22(dir)) {
7156
+ const dir = resolve6(trimmedWorkdir, ".apm", "webide", trimmedTaskId);
7157
+ if (existsSync23(dir)) {
6949
7158
  rmSync5(dir, { recursive: true, force: true });
6950
7159
  console.log(`[apm] \u5DF2\u6E05\u7406 WebIDE \u7F13\u5B58 ${dir}`);
6951
7160
  } else {
@@ -7296,17 +7505,17 @@ ${JSON.stringify(event, null, 2)}
7296
7505
  }
7297
7506
 
7298
7507
  // src/commands/connect/agent-session-registry.ts
7299
- import { existsSync as existsSync23, mkdirSync as mkdirSync9, readFileSync as readFileSync16, writeFileSync as writeFileSync14 } from "node:fs";
7300
- import { dirname as dirname6, resolve as resolve6 } from "node:path";
7508
+ import { existsSync as existsSync24, mkdirSync as mkdirSync10, readFileSync as readFileSync17, writeFileSync as writeFileSync15 } from "node:fs";
7509
+ import { dirname as dirname7, resolve as resolve7 } from "node:path";
7301
7510
  function registryPath(workdir, sessionId) {
7302
- return resolve6(workdir, ".apm", "sessions", sessionId, "cursor-agents.json");
7511
+ return resolve7(workdir, ".apm", "sessions", sessionId, "cursor-agents.json");
7303
7512
  }
7304
7513
  function readRegistry(path19) {
7305
- if (!existsSync23(path19)) {
7514
+ if (!existsSync24(path19)) {
7306
7515
  return {};
7307
7516
  }
7308
7517
  try {
7309
- const parsed = JSON.parse(readFileSync16(path19, "utf8"));
7518
+ const parsed = JSON.parse(readFileSync17(path19, "utf8"));
7310
7519
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
7311
7520
  const result = {};
7312
7521
  for (const [key, value] of Object.entries(
@@ -7323,8 +7532,8 @@ function readRegistry(path19) {
7323
7532
  return {};
7324
7533
  }
7325
7534
  function writeRegistry(path19, registry) {
7326
- mkdirSync9(dirname6(path19), { recursive: true });
7327
- writeFileSync14(path19, `${JSON.stringify(registry, null, 2)}
7535
+ mkdirSync10(dirname7(path19), { recursive: true });
7536
+ writeFileSync15(path19, `${JSON.stringify(registry, null, 2)}
7328
7537
  `, "utf8");
7329
7538
  }
7330
7539
  function loadSessionAgentId(workdir, sessionId, user) {
@@ -7927,12 +8136,12 @@ ${WORKSPACE_BOUNDARY_HINT}`;
7927
8136
  }
7928
8137
 
7929
8138
  // src/commands/connect/local-agent-store.ts
7930
- import { mkdirSync as mkdirSync10 } from "node:fs";
7931
- import { join as join18 } from "node:path";
8139
+ import { mkdirSync as mkdirSync11 } from "node:fs";
8140
+ import { join as join19 } from "node:path";
7932
8141
  import { JsonlLocalAgentStore } from "@cursor/sdk";
7933
8142
  function createWorkspaceLocalAgentStore(workdir) {
7934
- const rootDir = join18(workdir, ".apm", "cursor-agent-store");
7935
- mkdirSync10(rootDir, { recursive: true });
8143
+ const rootDir = join19(workdir, ".apm", "cursor-agent-store");
8144
+ mkdirSync11(rootDir, { recursive: true });
7936
8145
  return new JsonlLocalAgentStore(rootDir);
7937
8146
  }
7938
8147
 
@@ -8212,20 +8421,20 @@ async function ensureMessageHasReply(cfg, sessionId, messageId, fallback) {
8212
8421
  }
8213
8422
 
8214
8423
  // src/commands/connect/cli-version-sync.ts
8215
- import { existsSync as existsSync24, readFileSync as readFileSync17, writeFileSync as writeFileSync15 } from "fs";
8216
- import { join as join19 } from "path";
8424
+ import { existsSync as existsSync25, readFileSync as readFileSync18, writeFileSync as writeFileSync16 } from "fs";
8425
+ import { join as join20 } from "path";
8217
8426
  var CLI_VERSION_FILE = ".cli-version.json";
8218
- function manifestPath(apmDir) {
8219
- return join19(apmDir, CLI_VERSION_FILE);
8427
+ function manifestPath2(apmDir) {
8428
+ return join20(apmDir, CLI_VERSION_FILE);
8220
8429
  }
8221
8430
  function loadManifest4(apmDir) {
8222
- const path19 = toFsPath(manifestPath(apmDir));
8223
- if (!existsSync24(path19)) {
8431
+ const path19 = toFsPath(manifestPath2(apmDir));
8432
+ if (!existsSync25(path19)) {
8224
8433
  return null;
8225
8434
  }
8226
8435
  try {
8227
8436
  const parsed = JSON.parse(
8228
- readFileSync17(path19, "utf8")
8437
+ readFileSync18(path19, "utf8")
8229
8438
  );
8230
8439
  if (parsed?.version === 1 && typeof parsed.cliVersion === "string" && parsed.cliVersion.trim()) {
8231
8440
  return parsed;
@@ -8236,8 +8445,8 @@ function loadManifest4(apmDir) {
8236
8445
  }
8237
8446
  function saveManifest4(apmDir, cliVersion) {
8238
8447
  const manifest = { version: 1, cliVersion };
8239
- writeFileSync15(
8240
- toFsPath(manifestPath(apmDir)),
8448
+ writeFileSync16(
8449
+ toFsPath(manifestPath2(apmDir)),
8241
8450
  `${JSON.stringify(manifest, null, 2)}
8242
8451
  `,
8243
8452
  "utf8"
@@ -8290,7 +8499,7 @@ function createRunSlotPool(maxConcurrent = DEFAULT_MAX_CONCURRENT, options = {})
8290
8499
  );
8291
8500
  }
8292
8501
  const queuedAt = Date.now();
8293
- return new Promise((resolve7) => {
8502
+ return new Promise((resolve8) => {
8294
8503
  waiters.push(() => {
8295
8504
  active += 1;
8296
8505
  const waitedMs = Date.now() - queuedAt;
@@ -8301,7 +8510,7 @@ function createRunSlotPool(maxConcurrent = DEFAULT_MAX_CONCURRENT, options = {})
8301
8510
  )}s\uFF0C\u5F53\u524D\u5360\u7528 ${active}/${maxConcurrent}`
8302
8511
  );
8303
8512
  }
8304
- resolve7();
8513
+ resolve8();
8305
8514
  });
8306
8515
  });
8307
8516
  };
@@ -8322,9 +8531,9 @@ function createRunSlotPool(maxConcurrent = DEFAULT_MAX_CONCURRENT, options = {})
8322
8531
  init_webide_terminal_registry();
8323
8532
  import { Worker } from "node:worker_threads";
8324
8533
  import { fileURLToPath as fileURLToPath3 } from "node:url";
8325
- import { dirname as dirname7, join as join20 } from "node:path";
8326
- var workerFile = join20(
8327
- dirname7(fileURLToPath3(import.meta.url)),
8534
+ import { dirname as dirname8, join as join21 } from "node:path";
8535
+ var workerFile = join21(
8536
+ dirname8(fileURLToPath3(import.meta.url)),
8328
8537
  "webide-message-worker.js"
8329
8538
  );
8330
8539
  function spawnWebIdeMessageWorker(cfg, msg) {
@@ -8333,8 +8542,8 @@ function spawnWebIdeMessageWorker(cfg, msg) {
8333
8542
  });
8334
8543
  const registry = getWebIdeTerminalRegistry(cfg);
8335
8544
  let resolveDone;
8336
- const done = new Promise((resolve7) => {
8337
- resolveDone = resolve7;
8545
+ const done = new Promise((resolve8) => {
8546
+ resolveDone = resolve8;
8338
8547
  });
8339
8548
  worker.on("message", (m) => {
8340
8549
  if (m?.type === "terminal-rpc") {
@@ -8579,11 +8788,11 @@ async function handleInboundMessage(cfg, msg, signal, ctx) {
8579
8788
  }
8580
8789
  function interruptibleSleep(ms, signal) {
8581
8790
  if (signal.aborted) return Promise.resolve();
8582
- return new Promise((resolve7) => {
8583
- const timer = setTimeout(resolve7, ms);
8791
+ return new Promise((resolve8) => {
8792
+ const timer = setTimeout(resolve8, ms);
8584
8793
  const onAbort = () => {
8585
8794
  clearTimeout(timer);
8586
- resolve7();
8795
+ resolve8();
8587
8796
  };
8588
8797
  signal.addEventListener("abort", onAbort, { once: true });
8589
8798
  });
@@ -8795,7 +9004,7 @@ function attachWsHandlers(ws, ctx, onOpen) {
8795
9004
  });
8796
9005
  }
8797
9006
  function connectOnce(url, ctx, connectionAbort, onConnected) {
8798
- return new Promise((resolve7, reject) => {
9007
+ return new Promise((resolve8, reject) => {
8799
9008
  const ws = new WebSocket(url);
8800
9009
  let stopHeartbeat;
8801
9010
  let settled = false;
@@ -8824,7 +9033,7 @@ function connectOnce(url, ctx, connectionAbort, onConnected) {
8824
9033
  finish(() => reject(new Error("shutdown")));
8825
9034
  return;
8826
9035
  }
8827
- finish(resolve7);
9036
+ finish(resolve8);
8828
9037
  });
8829
9038
  ws.on("error", (err) => {
8830
9039
  console.error("[apm] WebSocket \u9519\u8BEF:", err.message);
@@ -9110,38 +9319,111 @@ function normalizeDeployEnvironment(env) {
9110
9319
  if (normalized === "online") return "ONLINE";
9111
9320
  return null;
9112
9321
  }
9322
+ async function resolveRepositoryIdForWebIdeDeploy(cwd, api) {
9323
+ const start = resolveWorkdirPath(cwd);
9324
+ let manifest = findWorkspaceReposManifestNearPath(start);
9325
+ if (!manifest) {
9326
+ throw new DeployExecutionError(
9327
+ "\u672A\u627E\u5230 .apm/workspace-repos.json\uFF0C\u65E0\u6CD5\u5339\u914D\u5E73\u53F0\u4ED3\u5E93",
9328
+ 1
9329
+ );
9330
+ }
9331
+ try {
9332
+ manifest = await enrichWorkspaceReposRemoteUrls(manifest);
9333
+ } catch (err) {
9334
+ const detail = err instanceof Error ? err.message : String(err);
9335
+ throw new DeployExecutionError(
9336
+ `\u5237\u65B0 workspace-repos remoteUrl \u5931\u8D25: ${detail}`,
9337
+ 1
9338
+ );
9339
+ }
9340
+ const entry = matchWorkspaceRepoEntryForPath(manifest, start);
9341
+ if (!entry) {
9342
+ throw new DeployExecutionError(
9343
+ `\u5F53\u524D\u76EE\u5F55\u672A\u547D\u4E2D workspace-repos \u4E2D\u7684\u4ED3\u5E93: ${start}`,
9344
+ 1
9345
+ );
9346
+ }
9347
+ const abs = absoluteRepoPath(manifest.workdir, entry);
9348
+ const remoteUrl = toHttpsGitRemoteUrl(entry.remoteUrl ?? "") || await tryReadHttpsGitOriginUrl(abs);
9349
+ if (!remoteUrl) {
9350
+ throw new DeployExecutionError(
9351
+ `\u4ED3 ${entry.path} \u65E0\u53EF\u7528\u7684 https remote\uFF0C\u65E0\u6CD5\u5339\u914D\u5E73\u53F0\u4ED3\u5E93`,
9352
+ 1
9353
+ );
9354
+ }
9355
+ let baseBranch = "";
9356
+ try {
9357
+ const gitRoot = await resolveGitRepoRoot(abs);
9358
+ baseBranch = (await resolveDefaultRemoteBranch(gitRoot)).trim();
9359
+ } catch (err) {
9360
+ const detail = err instanceof Error ? err.message : String(err);
9361
+ throw new DeployExecutionError(`\u89E3\u6790\u5F53\u524D\u4ED3\u57FA\u7EBF\u5206\u652F\u5931\u8D25: ${detail}`, 1);
9362
+ }
9363
+ if (!baseBranch) {
9364
+ throw new DeployExecutionError(
9365
+ "\u65E0\u6CD5\u786E\u5B9A\u5F53\u524D\u4ED3\u57FA\u7EBF\u5206\u652F\uFF0C\u65E0\u6CD5\u5339\u914D\u5E73\u53F0\u4ED3\u5E93",
9366
+ 1
9367
+ );
9368
+ }
9369
+ let matched;
9370
+ try {
9371
+ matched = await api.cli.matchRepository({
9372
+ url: remoteUrl,
9373
+ baseBranch
9374
+ });
9375
+ } catch (err) {
9376
+ const detail = err instanceof Error ? err.message : String(err);
9377
+ throw new DeployExecutionError(
9378
+ `\u6309 https remote + \u57FA\u7EBF\u5206\u652F\u5339\u914D\u5E73\u53F0\u4ED3\u5E93\u5931\u8D25: ${detail}`,
9379
+ 1
9380
+ );
9381
+ }
9382
+ const repositoryId = matched.repositoryId?.trim() || "";
9383
+ if (!repositoryId) {
9384
+ throw new DeployExecutionError(
9385
+ `\u672A\u5339\u914D\u5230\u5E73\u53F0\u4ED3\u5E93 path=${entry.path} url=${remoteUrl} baseBranch=${baseBranch}`,
9386
+ 1
9387
+ );
9388
+ }
9389
+ console.log(
9390
+ `[apm] \u90E8\u7F72\u8BB0\u5F55\u4ED3\u5E93 path=${entry.path} https+baseBranch=${baseBranch} \u2192 repositoryId=${repositoryId}`
9391
+ );
9392
+ return repositoryId;
9393
+ }
9113
9394
  async function runDeployWithBackendTracking(options) {
9395
+ const { tracking, ...deployOptions } = options;
9114
9396
  const cfg = await tryReadApmConfig();
9115
9397
  if (!cfg || !resolveApiKey(cfg)) {
9116
- console.warn("[apm] \u672A\u767B\u5F55\uFF0C\u8DF3\u8FC7\u540E\u7AEF\u90E8\u7F72\u8BB0\u5F55");
9117
- await executeDeploy(options);
9118
- return;
9398
+ throw new DeployExecutionError("\u672A\u767B\u5F55\uFF0C\u65E0\u6CD5\u521B\u5EFA\u90E8\u7F72\u8BB0\u5F55", 1);
9119
9399
  }
9120
- const environment = normalizeDeployEnvironment(options.env);
9400
+ const environment = normalizeDeployEnvironment(deployOptions.env);
9121
9401
  if (!environment) {
9122
- console.warn(
9123
- `[apm] \u672A\u77E5\u90E8\u7F72\u73AF\u5883 ${options.env}\uFF0C\u8DF3\u8FC7\u540E\u7AEF\u90E8\u7F72\u8BB0\u5F55\uFF08\u4EC5\u652F\u6301 test/online\uFF09`
9402
+ throw new DeployExecutionError(
9403
+ `\u672A\u77E5\u90E8\u7F72\u73AF\u5883 ${deployOptions.env}\uFF0C\u4EC5\u652F\u6301 test/online`,
9404
+ 1
9124
9405
  );
9125
- await executeDeploy(options);
9126
- return;
9127
9406
  }
9128
9407
  const api = createApmApiClient(cfg);
9408
+ const repositoryId = tracking.kind === "task" ? await resolveRepositoryIdForWebIdeDeploy(deployOptions.cwd, api) : void 0;
9129
9409
  let deploymentRunId;
9130
9410
  try {
9131
9411
  const run = await api.cli.createTaskDeployment({
9132
- sessionId: options.sessionId,
9412
+ ...tracking.kind === "session" ? { sessionId: tracking.sessionId } : { taskId: tracking.taskId },
9133
9413
  environment,
9134
- workdirPath: resolveWorkdirPath(options.cwd)
9414
+ workdirPath: resolveWorkdirPath(deployOptions.cwd),
9415
+ ...repositoryId ? { repositoryId } : {}
9135
9416
  });
9136
9417
  deploymentRunId = run.id;
9137
9418
  console.log(
9138
9419
  `[apm] \u5DF2\u521B\u5EFA\u90E8\u7F72\u8BB0\u5F55 id=${deploymentRunId} env=${environment}`
9139
9420
  );
9140
9421
  } catch (error) {
9422
+ if (error instanceof DeployExecutionError) {
9423
+ throw error;
9424
+ }
9141
9425
  const detail = error instanceof Error ? error.message : String(error);
9142
- console.warn(`[apm] \u521B\u5EFA\u90E8\u7F72\u8BB0\u5F55\u5931\u8D25\uFF0C\u7EE7\u7EED\u90E8\u7F72: ${detail}`);
9143
- await executeDeploy(options);
9144
- return;
9426
+ throw new DeployExecutionError(`\u521B\u5EFA\u90E8\u7F72\u8BB0\u5F55\u5931\u8D25: ${detail}`, 1);
9145
9427
  }
9146
9428
  await api.cli.updateTaskDeploymentStatus({
9147
9429
  id: deploymentRunId,
@@ -9152,7 +9434,7 @@ async function runDeployWithBackendTracking(options) {
9152
9434
  deploymentRunId,
9153
9435
  run: async (appendLog) => {
9154
9436
  const output = await executeDeploy({
9155
- ...options,
9437
+ ...deployOptions,
9156
9438
  captureOutput: true,
9157
9439
  archiveDeployArtifact: true
9158
9440
  });
@@ -9178,7 +9460,10 @@ function registerDeployMainCommand(program) {
9178
9460
  "apm.config.json \u8DEF\u5F84\uFF08\u9ED8\u8BA4 .apm/apm.config.json\uFF09"
9179
9461
  ).option(
9180
9462
  "--session <sessionId>",
9181
- "\u6C9F\u901A\u7FA4 ID\uFF1B\u4F20\u5165\u65F6\u5728\u5E73\u53F0\u521B\u5EFA\u90E8\u7F72\u8BB0\u5F55\u5E76\u540C\u6B65\u65E5\u5FD7"
9463
+ "\u6C9F\u901A\u7FA4 ID\uFF1B\u4F20\u5165\u65F6\u5728\u5E73\u53F0\u521B\u5EFA\u90E8\u7F72\u8BB0\u5F55\u5E76\u540C\u6B65\u65E5\u5FD7\uFF08\u4E0E --task \u4E8C\u9009\u4E00\uFF09"
9464
+ ).option(
9465
+ "--task <taskId>",
9466
+ "WebIDE \u4EFB\u52A1 ID\uFF1B\u4F20\u5165\u65F6\u5728\u5E73\u53F0\u521B\u5EFA\u90E8\u7F72\u8BB0\u5F55\u5E76\u540C\u6B65\u65E5\u5FD7\uFF08\u4E0E --session \u4E8C\u9009\u4E00\uFF09"
9182
9467
  ).option(
9183
9468
  "--pack-only",
9184
9469
  "\u4EC5\u6784\u5EFA/\u6253\u5305\u5E76\u4E0A\u4F20 MinIO \u5F52\u6863\uFF0C\u4E0D\u4E0A\u4F20\u8FDC\u7A0B SFTP/SSH\uFF08\u65E0\u9700 wisdomDeploy\uFF09"
@@ -9186,14 +9471,30 @@ function registerDeployMainCommand(program) {
9186
9471
  async (env, opts) => {
9187
9472
  const cwd = process.cwd();
9188
9473
  const sessionId = opts.session?.trim();
9474
+ const taskId = opts.task?.trim();
9189
9475
  const packOnly = Boolean(opts.packOnly);
9476
+ if (sessionId && taskId) {
9477
+ console.error("[apm] --session \u4E0E --task \u4E0D\u80FD\u540C\u65F6\u4F7F\u7528");
9478
+ process.exit(1);
9479
+ }
9190
9480
  try {
9191
9481
  if (sessionId) {
9192
9482
  await runDeployWithBackendTracking({
9193
9483
  env,
9194
9484
  cwd,
9195
9485
  configPath: opts.config,
9196
- sessionId,
9486
+ tracking: { kind: "session", sessionId },
9487
+ packOnly,
9488
+ deployTrigger: "session"
9489
+ });
9490
+ return;
9491
+ }
9492
+ if (taskId) {
9493
+ await runDeployWithBackendTracking({
9494
+ env,
9495
+ cwd,
9496
+ configPath: opts.config,
9497
+ tracking: { kind: "task", taskId },
9197
9498
  packOnly,
9198
9499
  deployTrigger: "session"
9199
9500
  });
@@ -9227,7 +9528,7 @@ import path15 from "node:path";
9227
9528
  import Docker from "dockerode";
9228
9529
 
9229
9530
  // src/commands/deploy/internal/backend-deploy/dockerode-client/connection-options.ts
9230
- import { existsSync as existsSync25, readFileSync as readFileSync18 } from "node:fs";
9531
+ import { existsSync as existsSync26, readFileSync as readFileSync19 } from "node:fs";
9231
9532
  import path12 from "node:path";
9232
9533
  function asOptionalTlsBuffer(value) {
9233
9534
  if (typeof value !== "string") {
@@ -9239,8 +9540,8 @@ function asOptionalTlsBuffer(value) {
9239
9540
  if (normalized === "") {
9240
9541
  return void 0;
9241
9542
  }
9242
- if (existsSync25(normalized)) {
9243
- return readFileSync18(normalized);
9543
+ if (existsSync26(normalized)) {
9544
+ return readFileSync19(normalized);
9244
9545
  }
9245
9546
  const looksLikePath = /[\\/]/.test(normalized) || normalized.endsWith(".pem");
9246
9547
  if (looksLikePath) {
@@ -9365,17 +9666,17 @@ var DockerodeClient = class {
9365
9666
  await this.client.getImage(image).remove({ force: true });
9366
9667
  }
9367
9668
  async pullImage(image, auth) {
9368
- const stream = await new Promise((resolve7, reject) => {
9669
+ const stream = await new Promise((resolve8, reject) => {
9369
9670
  const pullOptions = auth ? { authconfig: auth } : void 0;
9370
9671
  this.client.pull(image, pullOptions, (err, output) => {
9371
9672
  if (err || !output) {
9372
9673
  reject(err ?? new Error("docker pull \u8FD4\u56DE\u7A7A\u8F93\u51FA"));
9373
9674
  return;
9374
9675
  }
9375
- resolve7(output);
9676
+ resolve8(output);
9376
9677
  });
9377
9678
  });
9378
- await new Promise((resolve7, reject) => {
9679
+ await new Promise((resolve8, reject) => {
9379
9680
  this.client.modem.followProgress(
9380
9681
  stream,
9381
9682
  (err) => {
@@ -9383,7 +9684,7 @@ var DockerodeClient = class {
9383
9684
  reject(err);
9384
9685
  return;
9385
9686
  }
9386
- resolve7();
9687
+ resolve8();
9387
9688
  },
9388
9689
  () => void 0
9389
9690
  );
@@ -9450,7 +9751,7 @@ var DockerodeClient = class {
9450
9751
  var createDockerodeClient = (config) => new DockerodeClient(config);
9451
9752
 
9452
9753
  // src/commands/deploy/internal/backend-deploy/dockerode-client/env.ts
9453
- import { existsSync as existsSync26, readFileSync as readFileSync19, statSync as statSync10 } from "node:fs";
9754
+ import { existsSync as existsSync27, readFileSync as readFileSync20, statSync as statSync11 } from "node:fs";
9454
9755
  import path13 from "node:path";
9455
9756
  function stripSurroundingQuotes(value) {
9456
9757
  const t = value.trim();
@@ -9467,10 +9768,10 @@ function loadEnvFromFile(envFilePath) {
9467
9768
  return {};
9468
9769
  }
9469
9770
  const targetPath = path13.resolve(envFilePath);
9470
- if (!existsSync26(targetPath) || !statSync10(targetPath).isFile()) {
9771
+ if (!existsSync27(targetPath) || !statSync11(targetPath).isFile()) {
9471
9772
  return {};
9472
9773
  }
9473
- const raw = readFileSync19(targetPath, "utf-8");
9774
+ const raw = readFileSync20(targetPath, "utf-8");
9474
9775
  const result = {};
9475
9776
  for (const line of raw.split(/\r?\n/)) {
9476
9777
  const normalized = line.trim();
@@ -9641,12 +9942,12 @@ function dockerPushImage(params, cwd) {
9641
9942
  }
9642
9943
 
9643
9944
  // src/commands/deploy/internal/backend-deploy/resolve-dockerfile.ts
9644
- import { existsSync as existsSync27 } from "node:fs";
9945
+ import { existsSync as existsSync28 } from "node:fs";
9645
9946
  import path14 from "node:path";
9646
9947
  function resolveDockerBuildPaths(cwd) {
9647
9948
  const dockerfilePath = path14.join(cwd, "Dockerfile");
9648
9949
  Logger.info(`\u67E5\u627EDockerfile\u6587\u4EF6\uFF0C\u8DEF\u5F84: ${dockerfilePath}`);
9649
- if (!existsSync27(dockerfilePath)) {
9950
+ if (!existsSync28(dockerfilePath)) {
9650
9951
  throw new Error(`Dockerfile \u4E0D\u5B58\u5728\uFF1A${dockerfilePath}`);
9651
9952
  }
9652
9953
  Logger.info("\u2713 Dockerfile \u5B58\u5728");