cwm-assistant 0.3.9 → 0.3.10

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.
@@ -6,9 +6,9 @@ var __export = (target, all) => {
6
6
 
7
7
  // src/cli.ts
8
8
  import { spawn as spawn8 } from "node:child_process";
9
- import fs24 from "node:fs";
9
+ import fs25 from "node:fs";
10
10
  import os9 from "node:os";
11
- import path27 from "node:path";
11
+ import path28 from "node:path";
12
12
  import { createInterface } from "node:readline/promises";
13
13
 
14
14
  // ../../node_modules/@sinclair/typebox/build/esm/type/guard/value.mjs
@@ -2619,7 +2619,7 @@ var Type = type_exports2;
2619
2619
 
2620
2620
  // ../../packages/contracts/src/assistant.ts
2621
2621
  var ASSISTANT_PROTOCOL = 1;
2622
- var ASSISTANT_VERSION = "0.3.9";
2622
+ var ASSISTANT_VERSION = "0.3.10";
2623
2623
  var ASSISTANT_PORT = 46322;
2624
2624
 
2625
2625
  // ../../packages/contracts/src/index.ts
@@ -4281,8 +4281,8 @@ function registerAdoptRoutes(app, store, jobs) {
4281
4281
 
4282
4282
  // src/jobs.ts
4283
4283
  import { randomUUID as randomUUID6 } from "node:crypto";
4284
- import fs14 from "node:fs";
4285
- import path16 from "node:path";
4284
+ import fs15 from "node:fs";
4285
+ import path17 from "node:path";
4286
4286
 
4287
4287
  // ../../packages/runtime/src/workspaces/edit.ts
4288
4288
  import { randomUUID as randomUUID5 } from "node:crypto";
@@ -4546,6 +4546,52 @@ async function editLocalWorkspace(options) {
4546
4546
  }
4547
4547
  }
4548
4548
 
4549
+ // src/mount-relocation.ts
4550
+ import fs14 from "node:fs";
4551
+ import path16 from "node:path";
4552
+ async function relocateMount(options) {
4553
+ const { root, mount, log } = options;
4554
+ if (!inside3(mount.directory, mount.workspaceFile))
4555
+ throw new Error("\u672C\u673A\u526F\u672C\u7684 Workspace \u6587\u4EF6\u4E0D\u5728\u526F\u672C\u76EE\u5F55\u5185\uFF0C\u65E0\u6CD5\u968F\u5DE5\u4F5C\u76EE\u5F55\u79FB\u52A8");
4556
+ const target = checkedPath(root, path16.join(root, path16.basename(mount.directory)), false);
4557
+ if (fs14.existsSync(target)) throw new Error("\u65B0\u7684\u5DE5\u4F5C\u76EE\u5F55\u91CC\u5DF2\u6709\u540C\u540D\u76EE\u5F55\uFF1A" + target);
4558
+ log("\u5DE5\u4F5C\u76EE\u5F55\u5DF2\u53D8\u66F4\uFF0C\u79FB\u52A8\u672C\u673A\u526F\u672C\uFF1A" + mount.directory + " \u2192 " + target);
4559
+ try {
4560
+ fs14.renameSync(mount.directory, target);
4561
+ } catch (error) {
4562
+ if (error.code === "EXDEV")
4563
+ throw new Error("\u65B0\u7684\u5DE5\u4F5C\u76EE\u5F55\u4E0E\u65E7\u526F\u672C\u4E0D\u5728\u540C\u4E00\u78C1\u76D8\uFF0C\u65E0\u6CD5\u76F4\u63A5\u79FB\u52A8\uFF1B\u8BF7\u5148\u79FB\u9664\u672C\u673A\u526F\u672C\u540E\u91CD\u65B0\u6302\u8F7D");
4564
+ throw error;
4565
+ }
4566
+ const moved = {
4567
+ ...mount,
4568
+ managedRoot: root,
4569
+ directory: target,
4570
+ workspaceFile: path16.join(target, path16.basename(mount.workspaceFile))
4571
+ };
4572
+ for (const folder of workspaceFolders(moved)) {
4573
+ if (!folder) continue;
4574
+ await runGit(folder, ["worktree", "repair"]).catch(() => {
4575
+ });
4576
+ }
4577
+ return moved;
4578
+ }
4579
+ function workspaceFolders(mount) {
4580
+ try {
4581
+ const parsed = JSON.parse(fs14.readFileSync(mount.workspaceFile, "utf8"));
4582
+ return (parsed.folders ?? []).map((folder) => folder.path ? path16.resolve(mount.directory, folder.path) : "").filter((folder) => {
4583
+ if (!folder || !inside3(mount.directory, folder)) return false;
4584
+ try {
4585
+ return fs14.statSync(path16.join(folder, ".git")).isFile();
4586
+ } catch {
4587
+ return false;
4588
+ }
4589
+ });
4590
+ } catch {
4591
+ return [];
4592
+ }
4593
+ }
4594
+
4549
4595
  // src/jobs.ts
4550
4596
  var LocalJobs = class {
4551
4597
  constructor(store) {
@@ -4656,15 +4702,20 @@ var LocalJobs = class {
4656
4702
  job.state = "running";
4657
4703
  this.store.save();
4658
4704
  await gitExecution.run({ executable: state.git, signal: controller.signal }, async () => {
4659
- const root = fs14.realpathSync(state.root);
4705
+ const root = fs15.realpathSync(state.root);
4660
4706
  const definition = job.intent.definition;
4661
4707
  const mountKey = scopeKey(job.workbenchId, job.userId, definition.id);
4662
- const existingMount = state.mounts[mountKey];
4708
+ const recorded = state.mounts[mountKey];
4709
+ const existingMount = recorded && inside3(root, recorded.directory) ? recorded : recorded && fs15.existsSync(recorded.directory) ? await relocateMount({ root, mount: recorded, log }) : void 0;
4710
+ if (existingMount !== recorded && existingMount) {
4711
+ state.mounts[mountKey] = existingMount;
4712
+ this.store.save();
4713
+ }
4663
4714
  if (existingMount && definition.revision < existingMount.revision)
4664
4715
  throw new Error("\u4EFB\u52A1\u5B9A\u4E49\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u4F7F\u7528\u5F53\u524D\u5171\u4EAB\u5B9A\u4E49\u91CD\u65B0\u540C\u6B65");
4665
- const namespace = path16.join(root, ".cwm", job.workbenchId, job.userId);
4716
+ const namespace = path17.join(root, ".cwm", job.workbenchId, job.userId);
4666
4717
  checkedPath(root, namespace, false);
4667
- fs14.mkdirSync(namespace, { recursive: true });
4718
+ fs15.mkdirSync(namespace, { recursive: true });
4668
4719
  const prepared = [];
4669
4720
  for (const repo of definition.repositories) {
4670
4721
  controller.signal.throwIfAborted();
@@ -4672,9 +4723,9 @@ var LocalJobs = class {
4672
4723
  if (!source) {
4673
4724
  if (!/^(https:\/\/|ssh:\/\/|[\w.-]+@[\w.-]+:)/.test(repo.remoteUrl))
4674
4725
  throw new Error(`${repo.alias} \u7F3A\u5C11 HTTPS \u6216 SSH \u8FDC\u7A0B\u5730\u5740\uFF0C\u8BF7\u5148\u767B\u8BB0\u672C\u673A\u4ED3\u5E93`);
4675
- source = path16.join(namespace, repo.repositoryId);
4726
+ source = path17.join(namespace, repo.repositoryId);
4676
4727
  checkedPath(root, source, false);
4677
- if (!fs14.existsSync(source)) {
4728
+ if (!fs15.existsSync(source)) {
4678
4729
  const temporary = source + ".clone-" + randomUUID6();
4679
4730
  log("\u514B\u9686\u4ED3\u5E93\uFF1A" + repo.alias);
4680
4731
  try {
@@ -4683,17 +4734,17 @@ var LocalJobs = class {
4683
4734
  timeoutMs: 6e5
4684
4735
  });
4685
4736
  } catch (error) {
4686
- fs14.rmSync(temporary, { recursive: true, force: true });
4737
+ fs15.rmSync(temporary, { recursive: true, force: true });
4687
4738
  throw error;
4688
4739
  }
4689
- fs14.renameSync(temporary, source);
4740
+ fs15.renameSync(temporary, source);
4690
4741
  }
4691
4742
  if (await runGit(source, ["config", "--get", "remote.origin.url"]) !== repo.remoteUrl)
4692
4743
  throw new Error("\u4ED3\u5E93\u7F13\u5B58\u4E0E\u8FDC\u7A0B\u5730\u5740\u4E0D\u4E00\u81F4");
4693
4744
  state.repositories[scopeKey(job.workbenchId, job.userId, repo.repositoryId)] = source;
4694
4745
  this.store.save();
4695
4746
  }
4696
- if (!fs14.existsSync(source)) throw new Error("\u5DF2\u767B\u8BB0\u7684\u672C\u673A\u4ED3\u5E93\u4E0D\u5B58\u5728");
4747
+ if (!fs15.existsSync(source)) throw new Error("\u5DF2\u767B\u8BB0\u7684\u672C\u673A\u4ED3\u5E93\u4E0D\u5B58\u5728");
4697
4748
  if (repo.remoteUrl) {
4698
4749
  const configured = (await runGit(source, ["config", "--get", "remote.origin.url"])).replace(/(https?:\/\/)[^/@\s]+@/g, "$1");
4699
4750
  if (configured !== repo.remoteUrl)
@@ -4730,20 +4781,20 @@ var LocalJobs = class {
4730
4781
  subpath: repo.subpath
4731
4782
  });
4732
4783
  }
4733
- const destination = existingMount?.directory || path16.join(root, "cw-" + definition.slug);
4784
+ const destination = existingMount?.directory || path17.join(root, "cw-" + definition.slug);
4734
4785
  checkedPath(
4735
- existingMount ? path16.dirname(existingMount.directory) : root,
4786
+ existingMount ? path17.dirname(existingMount.directory) : root,
4736
4787
  destination,
4737
4788
  false
4738
4789
  );
4739
4790
  const key = scopeKey(job.workbenchId, job.userId, definition.id);
4740
- const marker = path16.join(destination, ".cwm-owner.json");
4741
- if (fs14.existsSync(destination)) {
4742
- if (!existingMount && !fs14.existsSync(marker) || fs14.existsSync(marker) && JSON.parse(fs14.readFileSync(marker, "utf8")).key !== key)
4791
+ const marker = path17.join(destination, ".cwm-owner.json");
4792
+ if (fs15.existsSync(destination)) {
4793
+ if (!existingMount && !fs15.existsSync(marker) || fs15.existsSync(marker) && JSON.parse(fs15.readFileSync(marker, "utf8")).key !== key)
4743
4794
  throw new Error("\u76EE\u5F55\u5DF2\u5B58\u5728\u4E14\u4E0D\u5C5E\u4E8E\u672C\u4EFB\u52A1\uFF0C\u8BF7\u5148\u5BFC\u5165\u6216\u66F4\u6362\u540D\u79F0");
4744
4795
  } else {
4745
- fs14.mkdirSync(destination);
4746
- fs14.writeFileSync(marker, JSON.stringify({ key }), { flag: "wx", mode: 384 });
4796
+ fs15.mkdirSync(destination);
4797
+ fs15.writeFileSync(marker, JSON.stringify({ key }), { flag: "wx", mode: 384 });
4747
4798
  }
4748
4799
  const result = existingMount ? await (async () => {
4749
4800
  localWorkspace(
@@ -4754,7 +4805,7 @@ var LocalJobs = class {
4754
4805
  checkedPath(existingMount.directory, existingMount.workspaceFile);
4755
4806
  await editLocalWorkspace({
4756
4807
  id: definition.id,
4757
- parent: path16.dirname(existingMount.directory),
4808
+ parent: path17.dirname(existingMount.directory),
4758
4809
  file: existingMount.workspaceFile,
4759
4810
  definition,
4760
4811
  sources: Object.fromEntries(
@@ -4776,7 +4827,7 @@ var LocalJobs = class {
4776
4827
  log
4777
4828
  );
4778
4829
  for (const repo of prepared) {
4779
- const document = JSON.parse(fs14.readFileSync(result.workspace, "utf8"));
4830
+ const document = JSON.parse(fs15.readFileSync(result.workspace, "utf8"));
4780
4831
  const folder = document.folders.find(
4781
4832
  (folder2) => folder2.name === repo.alias
4782
4833
  );
@@ -4784,7 +4835,7 @@ var LocalJobs = class {
4784
4835
  this.store,
4785
4836
  { workbenchId: job.workbenchId, userId: job.userId },
4786
4837
  definition.id
4787
- ).folders.find((item) => item.name === repo.alias).path : checkedPath(destination, path16.resolve(destination, folder.path));
4838
+ ).folders.find((item) => item.name === repo.alias).path : checkedPath(destination, path17.resolve(destination, folder.path));
4788
4839
  const branch = await runGit(directory, ["branch", "--show-current"]);
4789
4840
  if (branch !== repo.branch) throw new Error("\u672C\u673A\u5206\u652F\u6838\u9A8C\u5931\u8D25");
4790
4841
  await runGit(directory, ["rev-parse", "--verify", "HEAD"]);
@@ -4882,10 +4933,10 @@ async function fetchWorkbenchIdentity(origin) {
4882
4933
  import os8 from "node:os";
4883
4934
 
4884
4935
  // ../../packages/runtime/src/agent-sessions/service.ts
4885
- import path22 from "node:path";
4936
+ import path23 from "node:path";
4886
4937
 
4887
4938
  // ../../packages/runtime/src/agent-sessions/matching.ts
4888
- import path17 from "node:path";
4939
+ import path18 from "node:path";
4889
4940
  var SESSION_LIMIT = 40;
4890
4941
  function dedupeSessions(sessions) {
4891
4942
  const merged = /* @__PURE__ */ new Map();
@@ -4911,38 +4962,38 @@ function titleRank(title) {
4911
4962
  return 1;
4912
4963
  }
4913
4964
  function sessionMatches(cwd, scope) {
4914
- if (!cwd || !path17.isAbsolute(cwd)) return false;
4915
- const target = path17.resolve(cwd);
4965
+ if (!cwd || !path18.isAbsolute(cwd)) return false;
4966
+ const target = path18.resolve(cwd);
4916
4967
  if (sameOrInside(scope.containerDir, target)) return true;
4917
- if (scope.workspaceFile && path17.resolve(scope.workspaceFile) === target) return true;
4968
+ if (scope.workspaceFile && path18.resolve(scope.workspaceFile) === target) return true;
4918
4969
  return scope.mountPaths.some((mount) => Boolean(mount) && sameOrInside(mount, target));
4919
4970
  }
4920
4971
  function candidateDirectories(scope) {
4921
4972
  const values = [scope.containerDir, ...scope.mountPaths].filter(
4922
- (value) => value && path17.isAbsolute(value)
4973
+ (value) => value && path18.isAbsolute(value)
4923
4974
  );
4924
- return [...new Set(values.map((value) => path17.resolve(value)))];
4975
+ return [...new Set(values.map((value) => path18.resolve(value)))];
4925
4976
  }
4926
4977
  function sameOrInside(root, target) {
4927
- if (!root || !path17.isAbsolute(root)) return false;
4928
- const relative = path17.relative(path17.resolve(root), path17.resolve(target));
4929
- return relative === "" || !relative.startsWith("..") && !path17.isAbsolute(relative);
4978
+ if (!root || !path18.isAbsolute(root)) return false;
4979
+ const relative = path18.relative(path18.resolve(root), path18.resolve(target));
4980
+ return relative === "" || !relative.startsWith("..") && !path18.isAbsolute(relative);
4930
4981
  }
4931
4982
  function cursorSlug(directory) {
4932
- return path17.resolve(directory).split(path17.sep).filter(Boolean).join("-").replace(/:/g, "-");
4983
+ return path18.resolve(directory).split(path18.sep).filter(Boolean).join("-").replace(/:/g, "-");
4933
4984
  }
4934
4985
  function claudeSlug(directory) {
4935
- return path17.resolve(directory).split(path17.sep).join("-").replace(/:/g, "-");
4986
+ return path18.resolve(directory).split(path18.sep).join("-").replace(/:/g, "-");
4936
4987
  }
4937
4988
 
4938
4989
  // ../../packages/runtime/src/agent-sessions/providers/claude.ts
4939
- import fs16 from "node:fs";
4940
- import path19 from "node:path";
4990
+ import fs17 from "node:fs";
4991
+ import path20 from "node:path";
4941
4992
 
4942
4993
  // ../../packages/runtime/src/agent-sessions/storage.ts
4943
- import fs15 from "node:fs";
4994
+ import fs16 from "node:fs";
4944
4995
  import os7 from "node:os";
4945
- import path18 from "node:path";
4996
+ import path19 from "node:path";
4946
4997
  var PREFIX_BYTES = 65536;
4947
4998
  var TAIL_BYTES = 262144;
4948
4999
  function clipTitle(value) {
@@ -4951,23 +5002,23 @@ function clipTitle(value) {
4951
5002
  return text.length > 80 ? text.slice(0, 79) + "\u2026" : text;
4952
5003
  }
4953
5004
  function readPrefix(file, maxBytes = PREFIX_BYTES) {
4954
- const fd = fs15.openSync(file, "r");
5005
+ const fd = fs16.openSync(file, "r");
4955
5006
  try {
4956
5007
  const buffer = Buffer.alloc(maxBytes);
4957
- const size = fs15.readSync(fd, buffer, 0, maxBytes, 0);
5008
+ const size = fs16.readSync(fd, buffer, 0, maxBytes, 0);
4958
5009
  const text = buffer.subarray(0, size).toString("utf8");
4959
5010
  return size === maxBytes ? text.slice(0, text.lastIndexOf("\n")) : text;
4960
5011
  } finally {
4961
- fs15.closeSync(fd);
5012
+ fs16.closeSync(fd);
4962
5013
  }
4963
5014
  }
4964
5015
  function readTailRecords(file) {
4965
- const fd = fs15.openSync(file, "r");
5016
+ const fd = fs16.openSync(file, "r");
4966
5017
  try {
4967
- const size = fs15.fstatSync(fd).size;
5018
+ const size = fs16.fstatSync(fd).size;
4968
5019
  const start = Math.max(0, size - TAIL_BYTES);
4969
5020
  const buffer = Buffer.alloc(size - start);
4970
- const read = fs15.readSync(fd, buffer, 0, buffer.length, start);
5021
+ const read = fs16.readSync(fd, buffer, 0, buffer.length, start);
4971
5022
  const text = buffer.subarray(0, read).toString("utf8");
4972
5023
  const lines2 = text.split("\n");
4973
5024
  if (start > 0) lines2.shift();
@@ -4983,7 +5034,7 @@ function readTailRecords(file) {
4983
5034
  }
4984
5035
  return records;
4985
5036
  } finally {
4986
- fs15.closeSync(fd);
5037
+ fs16.closeSync(fd);
4987
5038
  }
4988
5039
  }
4989
5040
  function firstText(value, depth = 0) {
@@ -5021,17 +5072,17 @@ function parseFirstRecord(file) {
5021
5072
  }
5022
5073
  }
5023
5074
  function walkFiles(directory, include, depth) {
5024
- if (depth < 0 || !fs15.existsSync(directory)) return [];
5075
+ if (depth < 0 || !fs16.existsSync(directory)) return [];
5025
5076
  const files = [];
5026
- for (const entry of fs15.readdirSync(directory, { withFileTypes: true })) {
5027
- const target = path18.join(directory, entry.name);
5077
+ for (const entry of fs16.readdirSync(directory, { withFileTypes: true })) {
5078
+ const target = path19.join(directory, entry.name);
5028
5079
  if (entry.isDirectory()) files.push(...walkFiles(target, include, depth - 1));
5029
5080
  else if (include(entry.name)) files.push(target);
5030
5081
  }
5031
5082
  return files;
5032
5083
  }
5033
5084
  function agentStoragePaths(home, platform = process.platform, env = home === os7.homedir() ? process.env : {}) {
5034
- const paths = platform === "win32" ? path18.win32 : path18.posix;
5085
+ const paths = platform === "win32" ? path19.win32 : path19.posix;
5035
5086
  const cursorUser = platform === "darwin" ? paths.join(home, "Library", "Application Support", "Cursor", "User") : platform === "win32" ? paths.join(env.APPDATA || paths.join(home, "AppData", "Roaming"), "Cursor", "User") : paths.join(env.XDG_CONFIG_HOME || paths.join(home, ".config"), "Cursor", "User");
5036
5087
  return {
5037
5088
  cursorUser,
@@ -5112,13 +5163,13 @@ function listClaudeSessions(home, directories) {
5112
5163
  const sessions = [];
5113
5164
  for (const directory of directories) {
5114
5165
  const roots = [
5115
- .../* @__PURE__ */ new Set([claudeSlug(directory), path19.resolve(directory).replace(/[^A-Za-z0-9]/g, "-")])
5116
- ].map((slug) => path19.join(agentStoragePaths(home).claudeProjects, slug));
5166
+ .../* @__PURE__ */ new Set([claudeSlug(directory), path20.resolve(directory).replace(/[^A-Za-z0-9]/g, "-")])
5167
+ ].map((slug) => path20.join(agentStoragePaths(home).claudeProjects, slug));
5117
5168
  for (const root of roots) {
5118
- if (!fs16.existsSync(root)) continue;
5119
- for (const name of fs16.readdirSync(root)) {
5169
+ if (!fs17.existsSync(root)) continue;
5170
+ for (const name of fs17.readdirSync(root)) {
5120
5171
  if (!name.endsWith(".jsonl")) continue;
5121
- const file = path19.join(root, name);
5172
+ const file = path20.join(root, name);
5122
5173
  const record = claudeRecord(file, directory, name);
5123
5174
  if (record) sessions.push(record);
5124
5175
  }
@@ -5127,7 +5178,7 @@ function listClaudeSessions(home, directories) {
5127
5178
  return sessions;
5128
5179
  }
5129
5180
  function claudeRecord(file, directory, name) {
5130
- const stat2 = fs16.statSync(file);
5181
+ const stat2 = fs17.statSync(file);
5131
5182
  let cwd = directory;
5132
5183
  let title = "";
5133
5184
  let id = name.replace(/\.jsonl$/, "");
@@ -5156,11 +5207,11 @@ function claudeRecord(file, directory, name) {
5156
5207
  }
5157
5208
 
5158
5209
  // ../../packages/runtime/src/agent-sessions/providers/codex.ts
5159
- import fs17 from "node:fs";
5160
- import path20 from "node:path";
5210
+ import fs18 from "node:fs";
5211
+ import path21 from "node:path";
5161
5212
  function listCodexSessions(home, scope) {
5162
5213
  const root = agentStoragePaths(home).codexSessions;
5163
- if (!fs17.existsSync(root)) return [];
5214
+ if (!fs18.existsSync(root)) return [];
5164
5215
  const sessions = [];
5165
5216
  for (const file of walkFiles(
5166
5217
  root,
@@ -5184,7 +5235,7 @@ function codexRecord(file, scope) {
5184
5235
  }
5185
5236
  const cwd = meta.payload?.cwd || "";
5186
5237
  if (!sessionMatches(cwd, scope)) return void 0;
5187
- const stat2 = fs17.statSync(file);
5238
+ const stat2 = fs18.statSync(file);
5188
5239
  let title = meta.payload?.git?.branch || "";
5189
5240
  const titlePrefix = stat2.size > PREFIX_BYTES ? readPrefix(file, TAIL_BYTES) : prefix;
5190
5241
  for (const line of titlePrefix.split("\n").slice(1)) {
@@ -5211,7 +5262,7 @@ function codexRecord(file, scope) {
5211
5262
  }
5212
5263
  }
5213
5264
  return {
5214
- id: meta.payload?.session_id || meta.payload?.id || path20.basename(file),
5265
+ id: meta.payload?.session_id || meta.payload?.id || path21.basename(file),
5215
5266
  tool: "codex",
5216
5267
  title: clipTitle(title),
5217
5268
  cwd,
@@ -5221,17 +5272,17 @@ function codexRecord(file, scope) {
5221
5272
  }
5222
5273
 
5223
5274
  // ../../packages/runtime/src/agent-sessions/providers/cursor.ts
5224
- import fs19 from "node:fs";
5225
- import path21 from "node:path";
5275
+ import fs20 from "node:fs";
5276
+ import path22 from "node:path";
5226
5277
  import { fileURLToPath } from "node:url";
5227
5278
 
5228
5279
  // ../../packages/runtime/src/agent-sessions/sqlite-reader.ts
5229
- import fs18 from "node:fs";
5280
+ import fs19 from "node:fs";
5230
5281
  import { DatabaseSync } from "node:sqlite";
5231
5282
  var SqliteReader = class {
5232
5283
  database;
5233
5284
  constructor(file, _options) {
5234
- if (!fs18.existsSync(file)) throw new Error("\u4F1A\u8BDD\u6570\u636E\u5E93\u4E0D\u5B58\u5728");
5285
+ if (!fs19.existsSync(file)) throw new Error("\u4F1A\u8BDD\u6570\u636E\u5E93\u4E0D\u5B58\u5728");
5235
5286
  this.database = new DatabaseSync(file, { readOnly: true });
5236
5287
  }
5237
5288
  prepare(sql) {
@@ -5246,12 +5297,12 @@ var SqliteReader = class {
5246
5297
  function listCursorTranscripts(home, directories) {
5247
5298
  const sessions = [];
5248
5299
  for (const directory of directories) {
5249
- const root = path21.join(home, ".cursor", "projects", cursorSlug(directory), "agent-transcripts");
5250
- if (!fs19.existsSync(root)) continue;
5251
- for (const entry of fs19.readdirSync(root, { withFileTypes: true })) {
5252
- const file = entry.isDirectory() ? path21.join(root, entry.name, entry.name + ".jsonl") : path21.join(root, entry.name);
5253
- if (!file.endsWith(".jsonl") || !fs19.existsSync(file)) continue;
5254
- const stat2 = fs19.statSync(file);
5300
+ const root = path22.join(home, ".cursor", "projects", cursorSlug(directory), "agent-transcripts");
5301
+ if (!fs20.existsSync(root)) continue;
5302
+ for (const entry of fs20.readdirSync(root, { withFileTypes: true })) {
5303
+ const file = entry.isDirectory() ? path22.join(root, entry.name, entry.name + ".jsonl") : path22.join(root, entry.name);
5304
+ if (!file.endsWith(".jsonl") || !fs20.existsSync(file)) continue;
5305
+ const stat2 = fs20.statSync(file);
5255
5306
  const text = firstText(parseFirstRecord(file));
5256
5307
  sessions.push({
5257
5308
  id: entry.name.replace(/\.jsonl$/, ""),
@@ -5267,10 +5318,10 @@ function listCursorTranscripts(home, directories) {
5267
5318
  }
5268
5319
  function listCursorComposers(home, scope) {
5269
5320
  const root = agentStoragePaths(home).cursorUser;
5270
- const storage = path21.join(root, "workspaceStorage");
5271
- const databaseFile = path21.join(root, "globalStorage", "state.vscdb");
5321
+ const storage = path22.join(root, "workspaceStorage");
5322
+ const databaseFile = path22.join(root, "globalStorage", "state.vscdb");
5272
5323
  const workspaceIds = cursorWorkspaceIds(storage, scope);
5273
- if (!workspaceIds.length || !fs19.existsSync(databaseFile)) return [];
5324
+ if (!workspaceIds.length || !fs20.existsSync(databaseFile)) return [];
5274
5325
  try {
5275
5326
  const database = new SqliteReader(databaseFile, { readonly: true, fileMustExist: true });
5276
5327
  try {
@@ -5329,16 +5380,16 @@ function cursorStatus(database, id, header) {
5329
5380
  }
5330
5381
  }
5331
5382
  function cursorWorkspaceIds(storage, scope) {
5332
- if (!fs19.existsSync(storage)) return [];
5383
+ if (!fs20.existsSync(storage)) return [];
5333
5384
  const ids = [];
5334
- for (const entry of fs19.readdirSync(storage, { withFileTypes: true })) {
5385
+ for (const entry of fs20.readdirSync(storage, { withFileTypes: true })) {
5335
5386
  if (!entry.isDirectory()) continue;
5336
- const descriptor = path21.join(storage, entry.name, "workspace.json");
5337
- if (!fs19.existsSync(descriptor)) continue;
5387
+ const descriptor = path22.join(storage, entry.name, "workspace.json");
5388
+ if (!fs20.existsSync(descriptor)) continue;
5338
5389
  try {
5339
- const parsed = JSON.parse(fs19.readFileSync(descriptor, "utf8"));
5390
+ const parsed = JSON.parse(fs20.readFileSync(descriptor, "utf8"));
5340
5391
  const location = fileUriPath(parsed.workspace || "") || fileUriPath(parsed.folder || "");
5341
- if (location && (location === path21.resolve(scope.workspaceFile) || sessionMatches(location, scope)))
5392
+ if (location && (location === path22.resolve(scope.workspaceFile) || sessionMatches(location, scope)))
5342
5393
  ids.push(entry.name);
5343
5394
  } catch {
5344
5395
  }
@@ -5375,10 +5426,10 @@ function composerRecord(row, cwd) {
5375
5426
  }
5376
5427
 
5377
5428
  // ../../packages/runtime/src/agent-sessions/providers/opencode.ts
5378
- import fs20 from "node:fs";
5429
+ import fs21 from "node:fs";
5379
5430
  function listOpenCodeSessions(home, scope) {
5380
5431
  const databaseFile = agentStoragePaths(home).openCodeDatabase;
5381
- if (!fs20.existsSync(databaseFile)) return [];
5432
+ if (!fs21.existsSync(databaseFile)) return [];
5382
5433
  try {
5383
5434
  const database = new SqliteReader(databaseFile, { readonly: true, fileMustExist: true });
5384
5435
  try {
@@ -5427,7 +5478,7 @@ function agentSessionTarget(session) {
5427
5478
  if (session.tool === "claude")
5428
5479
  return CLAUDE_SESSION_ID.test(session.id) ? "claude://resume?session=" + encodeURIComponent(session.id) : void 0;
5429
5480
  if (session.tool === "codex") return "codex://threads/" + encodeURIComponent(session.id);
5430
- if (session.tool === "opencode" && path22.isAbsolute(session.cwd))
5481
+ if (session.tool === "opencode" && path23.isAbsolute(session.cwd))
5431
5482
  return "opencode://open-project?directory=" + encodeURIComponent(session.cwd);
5432
5483
  return void 0;
5433
5484
  }
@@ -5449,8 +5500,8 @@ function listAgentSessions(home, scope) {
5449
5500
  }
5450
5501
 
5451
5502
  // ../../packages/runtime/src/git/commits.ts
5452
- import fs21 from "node:fs";
5453
- import path23 from "node:path";
5503
+ import fs22 from "node:fs";
5504
+ import path24 from "node:path";
5454
5505
  var PAGE_SIZE = 20;
5455
5506
  var SYNC_INTERVAL_MS = 3e4;
5456
5507
  var comparisonSyncs = /* @__PURE__ */ new Map();
@@ -5471,8 +5522,8 @@ async function latestComparison(cwd, branch, force) {
5471
5522
  if (!(await git2(cwd, ["remote"])).split("\n").includes("origin"))
5472
5523
  return { unavailable: "\u4ED3\u5E93\u672A\u914D\u7F6E origin\uFF0C\u65E0\u6CD5\u8BFB\u53D6\u6700\u65B0 " + branch };
5473
5524
  const remoteRef = "refs/remotes/origin/" + branch;
5474
- const common = fs21.realpathSync(
5475
- path23.resolve(cwd, await git2(cwd, ["rev-parse", "--git-common-dir"]))
5525
+ const common = fs22.realpathSync(
5526
+ path24.resolve(cwd, await git2(cwd, ["rev-parse", "--git-common-dir"]))
5476
5527
  );
5477
5528
  const key = common + "\0" + await git2(cwd, ["remote", "get-url", "origin"]) + "\0" + branch;
5478
5529
  const cached = comparisonSyncs.get(key);
@@ -5520,7 +5571,7 @@ async function readWorkspaceCommits(mount, offset = 0, refresh = false) {
5520
5571
  baseRef: "origin/" + (compareBranch || "production")
5521
5572
  };
5522
5573
  if (!compareBranch) return { ...empty, unavailable: "\u4ED3\u5E93 Commit \u5BF9\u6BD4\u5206\u652F\u914D\u7F6E\u65E0\u6548" };
5523
- if (!mount.folder_path || !fs21.existsSync(mount.folder_path))
5574
+ if (!mount.folder_path || !fs22.existsSync(mount.folder_path))
5524
5575
  return { ...empty, unavailable: "\u6302\u8F7D\u8DEF\u5F84\u4E0D\u5B58\u5728" };
5525
5576
  try {
5526
5577
  const head = await git2(mount.folder_path, ["rev-parse", "--verify", "HEAD^{commit}"]);
@@ -5583,20 +5634,20 @@ function registerQueryRoutes(app, store) {
5583
5634
  app.get("/v1/repositories", async (request) => {
5584
5635
  const grant = requestGrant(request);
5585
5636
  const prefix = scopeKey(grant.workbenchId, grant.userId, "");
5586
- return Object.entries(store.state.repositories).filter(([key]) => key.startsWith(prefix)).map(([key, path28]) => ({ id: key.slice(prefix.length), path: path28 }));
5637
+ return Object.entries(store.state.repositories).filter(([key]) => key.startsWith(prefix)).map(([key, path29]) => ({ id: key.slice(prefix.length), path: path29 }));
5587
5638
  });
5588
5639
  app.post("/v1/repositories/inspect", async (request) => {
5589
5640
  const body = request.body;
5590
- const path28 = body.path;
5591
- if (!path28 || !(await import("node:path")).default.isAbsolute(path28))
5641
+ const path29 = body.path;
5642
+ if (!path29 || !(await import("node:path")).default.isAbsolute(path29))
5592
5643
  throw new Error("\u8BF7\u9009\u62E9\u7EDD\u5BF9\u8DEF\u5F84");
5593
5644
  return git4(async () => ({
5594
- root: await runGit(path28, ["rev-parse", "--show-toplevel"]),
5595
- remoteUrl: (await runGit(path28, ["remote", "get-url", "origin"]).catch(() => "")).replace(
5645
+ root: await runGit(path29, ["rev-parse", "--show-toplevel"]),
5646
+ remoteUrl: (await runGit(path29, ["remote", "get-url", "origin"]).catch(() => "")).replace(
5596
5647
  /(https?:\/\/)[^/@\s]+@/gi,
5597
5648
  "$1"
5598
5649
  ),
5599
- branches: (await runGit(path28, [
5650
+ branches: (await runGit(path29, [
5600
5651
  "for-each-ref",
5601
5652
  "--format=%(refname:short)",
5602
5653
  "refs/heads",
@@ -5650,11 +5701,11 @@ function registerQueryRoutes(app, store) {
5650
5701
  }
5651
5702
 
5652
5703
  // src/review-route.ts
5653
- import path25 from "node:path";
5704
+ import path26 from "node:path";
5654
5705
 
5655
5706
  // ../../packages/runtime/src/reviews/audit.ts
5656
- import fs22 from "node:fs";
5657
- import path24 from "node:path";
5707
+ import fs23 from "node:fs";
5708
+ import path25 from "node:path";
5658
5709
 
5659
5710
  // ../../packages/runtime/src/reviews/branch-scope.ts
5660
5711
  var lines = (text) => text ? text.split("\n") : [];
@@ -5855,14 +5906,14 @@ async function auditLocalVersion(initial, root, runId, inputHash, body, log) {
5855
5906
  const valid = (value) => typeof value === "string" && /^[A-Za-z0-9][A-Za-z0-9._/-]*$/.test(value) && !value.includes("..") && !value.endsWith("/");
5856
5907
  if (!valid(production) || !valid(staging) || production === staging)
5857
5908
  throw new Error("\u8BF7\u586B\u5199\u4E0D\u540C\u7684\u6709\u6548\u751F\u4EA7\u3001UAT \u5206\u652F\u540D");
5858
- fs22.mkdirSync(root, { recursive: true });
5909
+ fs23.mkdirSync(root, { recursive: true });
5859
5910
  const results = [], folders = [];
5860
5911
  const groups = [...new Set(includedMounts.map((mount) => mount.repository_id))];
5861
5912
  log("\u5BA1\u67E5\u4ED3\u5E93\u603B\u6570\uFF1A" + groups.length);
5862
5913
  excludedRepositories.forEach((repo) => log("\u5DF2\u6392\u9664\uFF1A" + repo.alias + "\uFF08" + repo.reason + "\uFF09"));
5863
5914
  for (const repositoryId of groups) {
5864
5915
  const entries = includedMounts.filter((entry) => entry.repository_id === repositoryId), repo = entries[0];
5865
- const directory = path24.join(root, repositoryId.replace(/[^a-zA-Z0-9_-]/g, "_"));
5916
+ const directory = path25.join(root, repositoryId.replace(/[^a-zA-Z0-9_-]/g, "_"));
5866
5917
  const result2 = {
5867
5918
  repositoryId,
5868
5919
  alias: repo.alias,
@@ -5878,10 +5929,10 @@ async function auditLocalVersion(initial, root, runId, inputHash, body, log) {
5878
5929
  let remote = repo.remote_url?.trim() || "";
5879
5930
  let localOrigin = false;
5880
5931
  if (!remote) {
5881
- if (!repo.canonical_path || !fs22.existsSync(repo.canonical_path))
5932
+ if (!repo.canonical_path || !fs23.existsSync(repo.canonical_path))
5882
5933
  throw new Error("\u8BF7\u914D\u7F6E\u8FDC\u7A0B\u4ED3\u5E93\u5730\u5740\u6216\u6709\u6548\u672C\u5730\u6765\u6E90");
5883
5934
  remote = await git3(repo.canonical_path, ["config", "--get", "remote.origin.url"]);
5884
- localOrigin = path24.isAbsolute(remote) && fs22.existsSync(remote);
5935
+ localOrigin = path25.isAbsolute(remote) && fs23.existsSync(remote);
5885
5936
  }
5886
5937
  if (!localOrigin && !/^(https:\/\/|ssh:\/\/|[\w.-]+@[\w.-]+:)/.test(remote) || remote.includes("::") || /[\s\x00-\x1f]/.test(remote) || /https?:\/\/[^/]*@/.test(remote))
5887
5938
  throw new Error("\u8FDC\u7AEF\u5730\u5740\u65E0\u6548");
@@ -5943,11 +5994,11 @@ async function auditLocalVersion(initial, root, runId, inputHash, body, log) {
5943
5994
  );
5944
5995
  const stale = false;
5945
5996
  const result = stale ? "STALE" : results.some((repo) => ["ERROR", "CONFLICT"].includes(repo.status)) ? "BLOCKED" : uncoveredRequirements.length || results.some((repo) => repo.status === "WARN") ? "WARN" : "PASS";
5946
- const workspaceFile = path24.join(
5997
+ const workspaceFile = path25.join(
5947
5998
  root,
5948
5999
  "version-" + initial.version.name.replace(/[^A-Za-z0-9._-]/g, "-") + ".code-workspace"
5949
6000
  );
5950
- fs22.writeFileSync(
6001
+ fs23.writeFileSync(
5951
6002
  workspaceFile,
5952
6003
  JSON.stringify(
5953
6004
  { folders, settings: { "codeWorkspace.description": "\u9694\u79BB\u5BA1\u67E5\u5FEB\u7167\uFF1B\u8BF7\u52FF\u7528\u4E8E\u53D1\u5E03\u63A8\u9001" } },
@@ -5970,8 +6021,8 @@ async function auditLocalVersion(initial, root, runId, inputHash, body, log) {
5970
6021
  stale
5971
6022
  };
5972
6023
  const report = readableReport(snapshot, result, createdAt, runId);
5973
- fs22.writeFileSync(path24.join(root, "report.md"), report, { mode: 384 });
5974
- fs22.writeFileSync(path24.join(root, "snapshot.json"), JSON.stringify(snapshot, null, 2), {
6024
+ fs23.writeFileSync(path25.join(root, "report.md"), report, { mode: 384 });
6025
+ fs23.writeFileSync(path25.join(root, "snapshot.json"), JSON.stringify(snapshot, null, 2), {
5975
6026
  mode: 384
5976
6027
  });
5977
6028
  return { runId, result, report, workspaceFile, snapshot, createdAt };
@@ -6003,7 +6054,7 @@ function registerReviewRoute(app, store, jobs) {
6003
6054
  },
6004
6055
  (log) => auditLocalVersion(
6005
6056
  snapshot,
6006
- path25.join(store.directory, "reviews", body.id),
6057
+ path26.join(store.directory, "reviews", body.id),
6007
6058
  body.id,
6008
6059
  body.inputHash,
6009
6060
  body,
@@ -6016,25 +6067,25 @@ function registerReviewRoute(app, store, jobs) {
6016
6067
 
6017
6068
  // src/upgrade.ts
6018
6069
  import { spawn as spawn7 } from "node:child_process";
6019
- import fs23 from "node:fs";
6020
- import path26 from "node:path";
6070
+ import fs24 from "node:fs";
6071
+ import path27 from "node:path";
6021
6072
  function packageRoot(entry) {
6022
- let directory = path26.dirname(path26.resolve(entry));
6073
+ let directory = path27.dirname(path27.resolve(entry));
6023
6074
  for (let depth = 0; depth < 4; depth++) {
6024
- if (fs23.existsSync(path26.join(directory, "package.json"))) return directory;
6025
- directory = path26.dirname(directory);
6075
+ if (fs24.existsSync(path27.join(directory, "package.json"))) return directory;
6076
+ directory = path27.dirname(directory);
6026
6077
  }
6027
- return path26.dirname(path26.dirname(path26.resolve(entry)));
6078
+ return path27.dirname(path27.dirname(path27.resolve(entry)));
6028
6079
  }
6029
6080
  function isGlobalInstall(root, prefix) {
6030
6081
  if (!prefix) return false;
6031
- const relative = path26.relative(path26.resolve(prefix), path26.resolve(root));
6032
- return Boolean(relative) && !relative.startsWith("..") && !path26.isAbsolute(relative);
6082
+ const relative = path27.relative(path27.resolve(prefix), path27.resolve(root));
6083
+ return Boolean(relative) && !relative.startsWith("..") && !path27.isAbsolute(relative);
6033
6084
  }
6034
6085
  function looksGlobal(root) {
6035
- const modules = path26.dirname(path26.resolve(root));
6036
- if (path26.basename(modules) !== "node_modules") return false;
6037
- return !fs23.existsSync(path26.join(path26.dirname(modules), "package.json"));
6086
+ const modules = path27.dirname(path27.resolve(root));
6087
+ if (path27.basename(modules) !== "node_modules") return false;
6088
+ return !fs24.existsSync(path27.join(path27.dirname(modules), "package.json"));
6038
6089
  }
6039
6090
  function isNewer(candidate, current) {
6040
6091
  const parse = (value) => value.split("-")[0].split(".").map((part) => Number(part) || 0);
@@ -6055,10 +6106,10 @@ async function latestPublished() {
6055
6106
  if (!data.version) throw new Error("npm \u8FD4\u56DE\u7684\u7248\u672C\u4FE1\u606F\u65E0\u6548");
6056
6107
  return data.version;
6057
6108
  }
6058
- var statusFile = (store) => path26.join(store.directory, "upgrade.json");
6109
+ var statusFile = (store) => path27.join(store.directory, "upgrade.json");
6059
6110
  function readStatus(store) {
6060
6111
  try {
6061
- return JSON.parse(fs23.readFileSync(statusFile(store), "utf8"));
6112
+ return JSON.parse(fs24.readFileSync(statusFile(store), "utf8"));
6062
6113
  } catch {
6063
6114
  return void 0;
6064
6115
  }
@@ -6102,7 +6153,7 @@ function registerUpgradeRoutes(app, store, entry, options = {}) {
6102
6153
  return reply.code(502).send({ error: cause.message });
6103
6154
  }
6104
6155
  if (!isNewer(latest, ASSISTANT_VERSION)) return { latest, started: false };
6105
- fs23.writeFileSync(
6156
+ fs24.writeFileSync(
6106
6157
  statusFile(store),
6107
6158
  JSON.stringify({ target: latest, state: "running", startedAt: (/* @__PURE__ */ new Date()).toISOString() }),
6108
6159
  { mode: 384 }
@@ -6110,7 +6161,7 @@ function registerUpgradeRoutes(app, store, entry, options = {}) {
6110
6161
  const child = spawn7(
6111
6162
  process.execPath,
6112
6163
  [
6113
- path26.join(root, "scripts", "upgrade.mjs"),
6164
+ path27.join(root, "scripts", "upgrade.mjs"),
6114
6165
  "--version",
6115
6166
  latest,
6116
6167
  "--state-dir",
@@ -6144,7 +6195,7 @@ async function buildAssistant(store, options = {}, entry, upgrade = {}) {
6144
6195
  return;
6145
6196
  }
6146
6197
  const origin = request.headers.origin || "";
6147
- const path28 = request.url.split("?")[0];
6198
+ const path29 = request.url.split("?")[0];
6148
6199
  let workbench = store.state.workbenches[origin];
6149
6200
  if (!workbench && trustedOrigin(origin)) {
6150
6201
  try {
@@ -6167,7 +6218,7 @@ async function buildAssistant(store, options = {}, entry, upgrade = {}) {
6167
6218
  reply.header("Access-Control-Allow-Headers", "Authorization, Content-Type, X-CWM-Binding");
6168
6219
  return reply.code(204).send();
6169
6220
  }
6170
- if (path28 === "/v1/health" || path28 === "/v1/pairings") return;
6221
+ if (path29 === "/v1/health" || path29 === "/v1/pairings") return;
6171
6222
  try {
6172
6223
  const token = request.headers.authorization?.replace(/^Bearer /, "") || "";
6173
6224
  const grant = verifyGrant(token, workbench.publicKey);
@@ -6341,7 +6392,7 @@ async function cli(args, entry) {
6341
6392
  return;
6342
6393
  }
6343
6394
  const dirIndex = args.indexOf("--state-dir");
6344
- const directory = dirIndex >= 0 ? path27.resolve(args[dirIndex + 1]) : defaultStateDirectory();
6395
+ const directory = dirIndex >= 0 ? path28.resolve(args[dirIndex + 1]) : defaultStateDirectory();
6345
6396
  const command = args[0] || "status";
6346
6397
  const store = new StateStore(directory);
6347
6398
  const control = async (action) => {
@@ -6367,7 +6418,7 @@ async function cli(args, entry) {
6367
6418
  }
6368
6419
  if (store.state.autostart) await startAutostart();
6369
6420
  else {
6370
- const log = fs24.openSync(path27.join(directory, "assistant.log"), "a", 384);
6421
+ const log = fs25.openSync(path28.join(directory, "assistant.log"), "a", 384);
6371
6422
  const child = spawn8(process.execPath, [entry, "serve", "--state-dir", directory], {
6372
6423
  detached: true,
6373
6424
  windowsHide: true,
@@ -6377,7 +6428,7 @@ async function cli(args, entry) {
6377
6428
  cwd: directory
6378
6429
  });
6379
6430
  child.unref();
6380
- fs24.closeSync(log);
6431
+ fs25.closeSync(log);
6381
6432
  }
6382
6433
  const deadline = Date.now() + 1e4;
6383
6434
  while (Date.now() < deadline) {
@@ -6392,18 +6443,18 @@ async function cli(args, entry) {
6392
6443
  throw new Error("\u542F\u52A8\u5931\u8D25\uFF0C\u8BF7\u8FD0\u884C cwm-assistant logs \u68C0\u67E5\u7AEF\u53E3\u548C\u8FD0\u884C\u73AF\u5883");
6393
6444
  }
6394
6445
  if (command === "serve") {
6395
- const lock = path27.join(directory, "process.lock");
6396
- if (fs24.existsSync(lock)) {
6397
- const pid = Number(fs24.readFileSync(lock, "utf8"));
6446
+ const lock = path28.join(directory, "process.lock");
6447
+ if (fs25.existsSync(lock)) {
6448
+ const pid = Number(fs25.readFileSync(lock, "utf8"));
6398
6449
  try {
6399
6450
  process.kill(pid, 0);
6400
6451
  throw new Error("Workspace \u52A9\u624B\u5DF2\u8FD0\u884C");
6401
6452
  } catch (error) {
6402
6453
  if (error.code !== "ESRCH") throw error;
6403
- fs24.unlinkSync(lock);
6454
+ fs25.unlinkSync(lock);
6404
6455
  }
6405
6456
  }
6406
- fs24.writeFileSync(lock, String(process.pid), { flag: "wx", mode: 384 });
6457
+ fs25.writeFileSync(lock, String(process.pid), { flag: "wx", mode: 384 });
6407
6458
  store.reload();
6408
6459
  store.recover();
6409
6460
  const { app, jobs } = await buildAssistant(store, {}, entry);
@@ -6427,12 +6478,12 @@ async function cli(args, entry) {
6427
6478
  return reply.code(400).send({ error: "\u63A7\u5236\u64CD\u4F5C\u65E0\u6548" });
6428
6479
  });
6429
6480
  app.addHook("onClose", async () => {
6430
- fs24.rmSync(lock, { force: true });
6481
+ fs25.rmSync(lock, { force: true });
6431
6482
  });
6432
6483
  try {
6433
6484
  await app.listen({ host: "127.0.0.1", port: ASSISTANT_PORT });
6434
6485
  } catch (error) {
6435
- fs24.rmSync(lock, { force: true });
6486
+ fs25.rmSync(lock, { force: true });
6436
6487
  throw error;
6437
6488
  }
6438
6489
  for (const signal of ["SIGTERM", "SIGINT"])
@@ -6457,7 +6508,7 @@ async function cli(args, entry) {
6457
6508
  await control("stop").catch(() => {
6458
6509
  });
6459
6510
  const deadline = Date.now() + 1e4;
6460
- while (fs24.existsSync(path27.join(directory, "process.lock")) && Date.now() < deadline) {
6511
+ while (fs25.existsSync(path28.join(directory, "process.lock")) && Date.now() < deadline) {
6461
6512
  await new Promise((resolve) => setTimeout(resolve, 100));
6462
6513
  }
6463
6514
  }
@@ -6489,9 +6540,9 @@ async function cli(args, entry) {
6489
6540
  return;
6490
6541
  }
6491
6542
  if (command === "logs") {
6492
- const file = path27.join(directory, "assistant.log");
6543
+ const file = path28.join(directory, "assistant.log");
6493
6544
  console.log(
6494
- fs24.existsSync(file) ? fs24.readFileSync(file, "utf8").split("\n").slice(-100).join("\n") : "\u6682\u65E0\u65E5\u5FD7"
6545
+ fs25.existsSync(file) ? fs25.readFileSync(file, "utf8").split("\n").slice(-100).join("\n") : "\u6682\u65E0\u65E5\u5FD7"
6495
6546
  );
6496
6547
  return;
6497
6548
  }
@@ -6506,10 +6557,10 @@ async function cli(args, entry) {
6506
6557
  await control("stop").catch(() => {
6507
6558
  });
6508
6559
  const deadline = Date.now() + 1e4;
6509
- while (fs24.existsSync(path27.join(directory, "process.lock")) && Date.now() < deadline) {
6560
+ while (fs25.existsSync(path28.join(directory, "process.lock")) && Date.now() < deadline) {
6510
6561
  await new Promise((resolve) => setTimeout(resolve, 100));
6511
6562
  }
6512
- if (fs24.existsSync(path27.join(directory, "process.lock")))
6563
+ if (fs25.existsSync(path28.join(directory, "process.lock")))
6513
6564
  throw new Error("\u52A9\u624B\u5C1A\u672A\u505C\u6B62\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\uFF1B\u672A\u4FEE\u6539\u672C\u5730\u72B6\u6001");
6514
6565
  }
6515
6566
  store.reload();
@@ -6544,11 +6595,11 @@ async function cli(args, entry) {
6544
6595
  {
6545
6596
  node: process.version,
6546
6597
  nodePath: process.execPath,
6547
- entryExists: fs24.existsSync(entry),
6598
+ entryExists: fs25.existsSync(entry),
6548
6599
  git: store.state.git,
6549
6600
  gitVersion,
6550
6601
  platform: process.platform,
6551
- rootExists: Boolean(store.state.root && fs24.existsSync(store.state.root)),
6602
+ rootExists: Boolean(store.state.root && fs25.existsSync(store.state.root)),
6552
6603
  configuredWorkbenches: Object.keys(store.state.workbenches),
6553
6604
  autostart: store.state.autostart,
6554
6605
  process: await control("status").catch(() => "\u672A\u8FD0\u884C")
@@ -6589,9 +6640,9 @@ async function cli(args, entry) {
6589
6640
  }
6590
6641
  }
6591
6642
  if (rootArg) {
6592
- if (!path27.isAbsolute(rootArg) || !fs24.statSync(rootArg).isDirectory())
6643
+ if (!path28.isAbsolute(rootArg) || !fs25.statSync(rootArg).isDirectory())
6593
6644
  throw new Error("\u5DE5\u4F5C\u76EE\u5F55\u5FC5\u987B\u662F\u5DF2\u5B58\u5728\u7684\u7EDD\u5BF9\u8DEF\u5F84");
6594
- store.state.root = fs24.realpathSync(rootArg);
6645
+ store.state.root = fs25.realpathSync(rootArg);
6595
6646
  }
6596
6647
  const auto = wantAutostart || !assumeYes && await ask("\u767B\u5F55\u7535\u8111\u65F6\u81EA\u52A8\u542F\u52A8\uFF1F[Y/n] ") !== "n";
6597
6648
  store.save();
@@ -6621,4 +6672,4 @@ async function cli(args, entry) {
6621
6672
  export {
6622
6673
  cli
6623
6674
  };
6624
- //# sourceMappingURL=cli-SBBYCWZE.js.map
6675
+ //# sourceMappingURL=cli-EWRIMGEP.js.map