@flemist/mcp-project-tools 5.0.0 → 5.0.2

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.
@@ -16,34 +16,34 @@ import { webkit as lr, firefox as cr, chromium as ur } from "playwright";
16
16
  import dr from "deepmerge";
17
17
  import Ne from "json5";
18
18
  import fr from "js-yaml";
19
- function pr(t) {
20
- const { authToken: r } = t;
19
+ function pr(r) {
20
+ const { authToken: t } = r;
21
21
  return function(o, e, n) {
22
- if ((o.query.token || o.headers.authorization?.replace("Bearer ", "")) !== r) {
22
+ if ((o.query.token || o.headers.authorization?.replace("Bearer ", "")) !== t) {
23
23
  e.status(401).json({ error: "Unauthorized" });
24
24
  return;
25
25
  }
26
26
  n();
27
27
  };
28
28
  }
29
- async function ie(t) {
30
- const { logFilePath: r, message: s, data: o } = t;
29
+ async function ie(r) {
30
+ const { logFilePath: t, message: s, data: o } = r;
31
31
  try {
32
32
  const e = (/* @__PURE__ */ new Date()).toISOString().replace(/[TZ]/g, " ").trim(), n = typeof o == "string" ? o : JSON.stringify(o, null, 2), i = `[${e}] ${s}
33
33
  ${n}
34
34
 
35
35
  `;
36
- await j.promises.mkdir(k.dirname(r), { recursive: !0 }), await j.promises.appendFile(r, i);
36
+ await j.promises.mkdir(k.dirname(t), { recursive: !0 }), await j.promises.appendFile(t, i);
37
37
  } catch (e) {
38
38
  console.error(`Failed to log "${s}":`, e);
39
39
  }
40
40
  }
41
41
  const ae = /* @__PURE__ */ new Map();
42
- function hr(t) {
43
- return t.headers["mcp-session-id"] || t.headers["x-session-id"] || t.query.token;
42
+ function hr(r) {
43
+ return r.headers["mcp-session-id"] || r.headers["x-session-id"] || r.query.token;
44
44
  }
45
- async function mr(t, r) {
46
- const s = await r.createMcpServer(t), o = new er({
45
+ async function mr(r, t) {
46
+ const s = await t.createMcpServer(r), o = new er({
47
47
  sessionIdGenerator: Xt,
48
48
  onsessioninitialized: (n) => {
49
49
  ae.set(n, o);
@@ -66,28 +66,28 @@ async function mr(t, r) {
66
66
  throw await e(), n;
67
67
  }
68
68
  }
69
- async function gr(t, r, s, o) {
69
+ async function gr(r, t, s, o) {
70
70
  await ie({
71
71
  logFilePath: s.logFilePath,
72
72
  message: "REQUEST",
73
- data: t.body
73
+ data: r.body
74
74
  });
75
75
  let e = o ? ae.get(o) : null;
76
- e || (e = await mr(t, s)), await e.handleRequest(t, r, t.body);
76
+ e || (e = await mr(r, s)), await e.handleRequest(r, t, r.body);
77
77
  }
78
- async function wr(t, r, s) {
78
+ async function wr(r, t, s) {
79
79
  const o = s ? ae.get(s) : null;
80
80
  if (!o) {
81
- r.status(400).json({ error: "No valid session found" });
81
+ t.status(400).json({ error: "No valid session found" });
82
82
  return;
83
83
  }
84
- await o.handleRequest(t, r);
84
+ await o.handleRequest(r, t);
85
85
  }
86
- function yr(t) {
86
+ function yr(r) {
87
87
  return async function(s, o) {
88
88
  try {
89
89
  const e = hr(s);
90
- s.method === "POST" ? await gr(s, o, t, e) : s.method === "GET" ? await wr(s, o, e) : o.status(405).json({ error: "Method not allowed" });
90
+ s.method === "POST" ? await gr(s, o, r, e) : s.method === "GET" ? await wr(s, o, e) : o.status(405).json({ error: "Method not allowed" });
91
91
  } catch (e) {
92
92
  console.error("Unhandled error in streamableHttpHandler", e), o.status(500).json({
93
93
  error: "Internal server error: " + (e instanceof Error ? e.message : "Unknown error")
@@ -98,11 +98,11 @@ function yr(t) {
98
98
  const Y = /* @__PURE__ */ new Map();
99
99
  let br = 0;
100
100
  const ke = 10, Sr = 1800 * 1e3, J = 1e4, Q = 2e3, xr = 5e3;
101
- function $r(t) {
102
- const { commandLine: r, commandLineRules: s } = t;
101
+ function Ir(r) {
102
+ const { commandLine: t, commandLineRules: s } = r;
103
103
  let o = !1;
104
104
  for (const e of s)
105
- if (new RegExp(e.regexp).test(r))
105
+ if (new RegExp(e.regexp).test(t))
106
106
  switch (e.rule) {
107
107
  case "allow":
108
108
  o = !0;
@@ -115,7 +115,7 @@ function $r(t) {
115
115
  }
116
116
  return o;
117
117
  }
118
- function Ir() {
118
+ function $r() {
119
119
  return ++br;
120
120
  }
121
121
  let Oe = !1;
@@ -123,49 +123,49 @@ function Mr() {
123
123
  if (Oe)
124
124
  return;
125
125
  Oe = !0;
126
- const t = () => {
126
+ const r = () => {
127
127
  console.log("Auto-killing all child processes...");
128
- for (const [r, s] of Array.from(Y.entries()))
128
+ for (const [t, s] of Array.from(Y.entries()))
129
129
  if (s.isRunning && s.pid)
130
130
  try {
131
131
  he(s.pid, "SIGKILL");
132
132
  } catch (o) {
133
- console.error(`Error killing process ${r}:`, o);
133
+ console.error(`Error killing process ${t}:`, o);
134
134
  }
135
135
  process.exit(0);
136
136
  };
137
- process.on("SIGINT", t), process.on("SIGTERM", t);
137
+ process.on("SIGINT", r), process.on("SIGTERM", r);
138
138
  }
139
139
  function ge() {
140
- const t = Date.now(), r = [];
140
+ const r = Date.now(), t = [];
141
141
  for (const [s, o] of Array.from(Y.entries()))
142
- !o.isRunning && o.endTime && t - o.endTime.getTime() > Sr && r.push(s);
143
- for (const s of r)
142
+ !o.isRunning && o.endTime && r - o.endTime.getTime() > Sr && t.push(s);
143
+ for (const s of t)
144
144
  Y.delete(s);
145
145
  }
146
- function Re(t) {
147
- return t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
146
+ function Re(r) {
147
+ return r.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
148
148
  }
149
149
  const De = "[/\\\\]";
150
- function at(t, r) {
151
- const s = t.replace(/[\\/]+$/, "");
150
+ function at(r, t) {
151
+ const s = r.replace(/[\\/]+$/, "");
152
152
  let o;
153
- return r ? o = s.split(/[\\/]/).map(Re).join(De) : o = Re(s), o += `(?=${De}|$)`, new RegExp(o, r ? "gi" : "g");
153
+ return t ? o = s.split(/[\\/]/).map(Re).join(De) : o = Re(s), o += `(?=${De}|$)`, new RegExp(o, t ? "gi" : "g");
154
154
  }
155
- function Tr(t, r, s, o) {
156
- const e = at(r, o);
157
- return t.replace(e, (n) => s + n.slice(r.length));
155
+ function Tr(r, t, s, o) {
156
+ const e = at(t, o);
157
+ return r.replace(e, (n) => s + n.slice(t.length));
158
158
  }
159
- function Cr(t, r, s, o) {
159
+ function Cr(r, t, s, o) {
160
160
  const e = process.platform === "win32", n = {};
161
161
  if (s !== "clear") if (s === "replaceServerPaths" || s === "deleteServerPaths") {
162
- const i = Fe(t, e), a = Fe(r, e);
162
+ const i = Fe(r, e), a = Fe(t, e);
163
163
  if (i !== a) {
164
- const l = at(t, e);
164
+ const l = at(r, e);
165
165
  for (const u in process.env) {
166
166
  if (!Object.prototype.hasOwnProperty.call(process.env, u)) continue;
167
167
  const f = process.env[u];
168
- f != null && (l.lastIndex = 0, l.test(f) ? s === "replaceServerPaths" && (n[u] = Tr(f, t, r, e)) : n[u] = f);
168
+ f != null && (l.lastIndex = 0, l.test(f) ? s === "replaceServerPaths" && (n[u] = Tr(f, r, t, e)) : n[u] = f);
169
169
  }
170
170
  } else
171
171
  for (const l in process.env) {
@@ -187,41 +187,41 @@ function Cr(t, r, s, o) {
187
187
  }
188
188
  return n;
189
189
  }
190
- function Fe(t, r) {
191
- const s = k.normalize(t).replace(/[\\/]+$/, "");
192
- return r ? s.toLowerCase() : s;
190
+ function Fe(r, t) {
191
+ const s = k.normalize(r).replace(/[\\/]+$/, "");
192
+ return t ? s.toLowerCase() : s;
193
193
  }
194
194
  const vr = 1800 * 1e3, Pe = /* @__PURE__ */ new Map();
195
195
  let Er = 0;
196
196
  function Nr() {
197
197
  return ++Er;
198
198
  }
199
- function lt(t) {
200
- let r = Pe.get(t);
201
- return r == null && (r = {
199
+ function lt(r) {
200
+ let t = Pe.get(r);
201
+ return t == null && (t = {
202
202
  storedOutputs: /* @__PURE__ */ new Map()
203
- }, Pe.set(t, r)), r;
203
+ }, Pe.set(r, t)), t;
204
204
  }
205
- function ct(t) {
206
- return typeof t == "function" ? t() : t;
205
+ function ct(r) {
206
+ return typeof r == "function" ? r() : r;
207
207
  }
208
- function ut(t, r) {
208
+ function ut(r, t) {
209
209
  return setTimeout(() => {
210
- t.storedOutputs.delete(r);
210
+ r.storedOutputs.delete(t);
211
211
  }, vr);
212
212
  }
213
- function kr(t, r, s) {
214
- clearTimeout(s.cleanupTimer), s.cleanupTimer = ut(t, r);
213
+ function kr(r, t, s) {
214
+ clearTimeout(s.cleanupTimer), s.cleanupTimer = ut(r, t);
215
215
  }
216
- function Or(t) {
217
- const { sessionId: r, source: s } = t, o = lt(r), e = Nr(), n = {
216
+ function Or(r) {
217
+ const { sessionId: t, source: s } = r, o = lt(t), e = Nr(), n = {
218
218
  source: s,
219
219
  cleanupTimer: ut(o, e)
220
220
  };
221
221
  return o.storedOutputs.set(e, n), e;
222
222
  }
223
- function dt(t) {
224
- const { sessionId: r, outputId: s, range: o } = t, [e, n] = o, i = lt(r), a = i.storedOutputs.get(s);
223
+ function dt(r) {
224
+ const { sessionId: t, outputId: s, range: o } = r, [e, n] = o, i = lt(t), a = i.storedOutputs.get(s);
225
225
  if (a == null)
226
226
  return {
227
227
  content: "",
@@ -233,12 +233,12 @@ function dt(t) {
233
233
  const c = ct(a.source), l = c.length, u = Math.min(Math.max(e, 0), l), f = Math.min(Math.max(n, 0), l);
234
234
  return { content: c.substring(u, f), total: l, range: [u, f] };
235
235
  }
236
- function we(t) {
237
- const { sessionId: r, source: s, limit: o } = t, e = ct(s);
236
+ function we(r) {
237
+ const { sessionId: t, source: s, limit: o } = r, e = ct(s);
238
238
  if (e.length <= o)
239
239
  return { content: e, outputId: null };
240
- const n = Or({ sessionId: r, source: s }), i = dt({
241
- sessionId: r,
240
+ const n = Or({ sessionId: t, source: s }), i = dt({
241
+ sessionId: t,
242
242
  outputId: n,
243
243
  range: [0, o]
244
244
  }), a = `
@@ -248,8 +248,8 @@ function we(t) {
248
248
  outputId: n
249
249
  };
250
250
  }
251
- function F(t) {
252
- return `Invalid arguments: ${t instanceof Error ? t.message : "Unknown error"}.
251
+ function F(r) {
252
+ return `Invalid arguments: ${r instanceof Error ? r.message : "Unknown error"}.
253
253
 
254
254
  Provide valid parameters according to schema.`;
255
255
  }
@@ -265,30 +265,23 @@ const ft = m.object({
265
265
  `Character range to retrieve. Maximum range size: ${J}.`
266
266
  )
267
267
  });
268
- function Dr(t, r) {
268
+ function Dr(r, t) {
269
269
  let s;
270
270
  try {
271
- s = pt.parse(t);
271
+ s = pt.parse(r);
272
272
  } catch (i) {
273
273
  return {
274
274
  error: F(i)
275
275
  };
276
276
  }
277
- if (!r.sessionId)
277
+ if (!t.sessionId)
278
278
  return {
279
279
  error: "Session ID is required"
280
280
  };
281
- const { from: o, toExclusive: e } = s.range;
282
- if (e <= o)
283
- return {
284
- error: `Invalid range: to (${e}) must be greater than from (${o})`
285
- };
286
- if (e - o > J)
287
- return {
288
- error: `Range size ${e - o} exceeds maximum ${J}`
289
- };
281
+ let { from: o, toExclusive: e } = s.range;
282
+ e <= o && (e = o), e - o > J && (e = o + J);
290
283
  const n = dt({
291
- sessionId: r.sessionId,
284
+ sessionId: t.sessionId,
292
285
  outputId: s.outputId,
293
286
  range: [o, e]
294
287
  });
@@ -298,21 +291,21 @@ function Dr(t, r) {
298
291
  range: n.range
299
292
  };
300
293
  }
301
- function Fr(t) {
302
- t(
294
+ function Fr(r) {
295
+ r(
303
296
  "output-read",
304
297
  {
305
298
  title: "Read Stored Output Range",
306
299
  description: "Read any range from stored output. Use outputId from truncation message and specify character range [from, to).",
307
300
  inputSchema: pt.shape
308
301
  },
309
- async (r, s) => {
310
- const o = Dr(r, s);
302
+ async (t, s) => {
303
+ const o = Dr(t, s);
311
304
  if (o.error != null)
312
- return `Method: output-read(${JSON.stringify(r)})
305
+ return `Method: output-read(${JSON.stringify(t)})
313
306
  ❌ Error: ${o.error}`;
314
307
  const [e, n] = o.range, i = o.total;
315
- let a = `Method: output-read(${JSON.stringify(r)})
308
+ let a = `Method: output-read(${JSON.stringify(t)})
316
309
  showing [${e}, ${n}) of ${i} chars`;
317
310
  return e >= i && (a += `
318
311
  ⚠️ Warning: requested range is beyond content (total: ${i} chars)`), a += `
@@ -321,8 +314,8 @@ ${o.content}`, a;
321
314
  }
322
315
  );
323
316
  }
324
- function Pr(t) {
325
- Fr(t);
317
+ function Pr(r) {
318
+ Fr(r);
326
319
  }
327
320
  const ht = m.object({
328
321
  id: m.number().describe(
@@ -332,11 +325,11 @@ const ht = m.object({
332
325
  `Maximum output characters to return. Truncated output can be retrieved via output-read tool using outputId from truncation message. Maximum: ${J}. Default: ${Q}`
333
326
  )
334
327
  });
335
- async function ye(t, r, s) {
328
+ async function ye(r, t, s) {
336
329
  ge();
337
330
  let o;
338
331
  try {
339
- o = ht.parse(t);
332
+ o = ht.parse(r);
340
333
  } catch (c) {
341
334
  return {
342
335
  error: F(c)
@@ -358,7 +351,7 @@ async function ye(t, r, s) {
358
351
  }).content;
359
352
  return {
360
353
  id: i.id,
361
- cwd: k.relative(r.workingDir || "", i.cwd),
354
+ cwd: k.relative(t.workingDir || "", i.cwd),
362
355
  commandLine: i.commandLine,
363
356
  pid: i.pid,
364
357
  startTime: i.startTime.toISOString().replace(/[TZ]/g, " ").trim(),
@@ -369,8 +362,8 @@ async function ye(t, r, s) {
369
362
  error: i.error
370
363
  };
371
364
  }
372
- function Br(t, r) {
373
- t(
365
+ function Br(r, t) {
366
+ r(
374
367
  "process-status",
375
368
  {
376
369
  title: "Get Host Machine Process Status",
@@ -378,7 +371,7 @@ function Br(t, r) {
378
371
  inputSchema: ht.shape
379
372
  },
380
373
  async (s, o) => {
381
- const e = await ye(s, r, o);
374
+ const e = await ye(s, t, o);
382
375
  if (!("output" in e))
383
376
  return `Method: process-status(${JSON.stringify(s)})
384
377
  ❌ Error: ${e.error}`;
@@ -391,12 +384,12 @@ ${n.trim()}`;
391
384
  }
392
385
  );
393
386
  }
394
- function mt(t) {
395
- he(t, "SIGTERM", (r) => {
396
- r && !r.message.includes("not found") && console.error(`Error sending SIGTERM to process ${t}:`, r);
387
+ function mt(r) {
388
+ he(r, "SIGTERM", (t) => {
389
+ t && !t.message.includes("not found") && console.error(`Error sending SIGTERM to process ${r}:`, t);
397
390
  }), setTimeout(() => {
398
- he(t, "SIGKILL", (r) => {
399
- r && !r.message.includes("not found") && console.error(`Error sending SIGKILL to process ${t}:`, r);
391
+ he(r, "SIGKILL", (t) => {
392
+ t && !t.message.includes("not found") && console.error(`Error sending SIGKILL to process ${r}:`, t);
400
393
  });
401
394
  }, xr);
402
395
  }
@@ -414,10 +407,10 @@ const gt = m.object({
414
407
  `Maximum output characters to return. Truncated output can be retrieved via output-read tool using outputId from truncation message. Maximum: ${J}. Default: ${Q}`
415
408
  )
416
409
  });
417
- async function wt(t, r, s) {
410
+ async function wt(r, t, s) {
418
411
  let o;
419
412
  try {
420
- o = gt.parse(t);
413
+ o = gt.parse(r);
421
414
  } catch (h) {
422
415
  return {
423
416
  error: F(h)
@@ -437,14 +430,14 @@ async function wt(t, r, s) {
437
430
  });
438
431
  const d = (Date.now() - l) / 1e3;
439
432
  return {
440
- ...await ye({ id: e, outputLimit: a }, r, s),
433
+ ...await ye({ id: e, outputLimit: a }, t, s),
441
434
  waitDuration: d,
442
435
  waitTimeExceeded: u,
443
436
  autoKillExecuted: f
444
437
  };
445
438
  }
446
- function Lr(t, r) {
447
- t(
439
+ function Lr(r, t) {
440
+ r(
448
441
  "process-wait",
449
442
  {
450
443
  title: "Wait for Host Machine Process",
@@ -452,7 +445,7 @@ function Lr(t, r) {
452
445
  inputSchema: gt.shape
453
446
  },
454
447
  async (s, o) => {
455
- const e = await wt(s, r, o);
448
+ const e = await wt(s, t, o);
456
449
  if (!("output" in e))
457
450
  return `Method: process-wait(${JSON.stringify(s)})
458
451
  ❌ Error: ${e.error}`;
@@ -465,17 +458,17 @@ ${n.trim()}`;
465
458
  }
466
459
  );
467
460
  }
468
- function H(t) {
469
- return t.replace(/\\/g, "/");
461
+ function H(r) {
462
+ return r.replace(/\\/g, "/");
470
463
  }
471
- function be(t, r) {
472
- if (!t)
464
+ function be(r, t) {
465
+ if (!r)
473
466
  return { error: "Working directory is not configured" };
474
- const s = H(k.resolve(t)), o = H(
475
- k.resolve(t, r || "")
467
+ const s = H(k.resolve(r)), o = H(
468
+ k.resolve(r, t || "")
476
469
  );
477
470
  return !o.startsWith(s + "/") && o !== s ? {
478
- error: `Path "${r}" escapes root directory "${t}". Resolved path: "${o}"`
471
+ error: `Path "${t}" escapes root directory "${r}". Resolved path: "${o}"`
479
472
  } : { path: o };
480
473
  }
481
474
  const yt = m.object({
@@ -495,24 +488,24 @@ const yt = m.object({
495
488
  `Maximum output characters to return. Truncated output can be retrieved via output-read tool using outputId from truncation message. Maximum: ${J}. Default: ${Q}`
496
489
  )
497
490
  });
498
- async function Ar(t, r, s) {
491
+ async function Ar(r, t, s) {
499
492
  ge();
500
493
  let o;
501
494
  try {
502
- o = yt.parse(t);
495
+ o = yt.parse(r);
503
496
  } catch (h) {
504
497
  return {
505
498
  error: F(h)
506
499
  };
507
500
  }
508
- const { commandLine: e, waitTime: n, autoKill: i, outputLimit: a } = o, { commandLineRules: c } = r, l = be(
509
- r.workingDir,
501
+ const { commandLine: e, waitTime: n, autoKill: i, outputLimit: a } = o, { commandLineRules: c } = t, l = be(
502
+ t.workingDir,
510
503
  o.relativeRootDir
511
504
  );
512
505
  if ("error" in l)
513
506
  return { error: l.error };
514
507
  const u = l.path;
515
- if (!$r({ commandLine: e, commandLineRules: c })) {
508
+ if (!Ir({ commandLine: e, commandLineRules: c })) {
516
509
  const h = c.map(
517
510
  (g) => `${g.rule.toUpperCase()}: /${g.regexp}/ (${g.note})`
518
511
  ).join(`
@@ -530,7 +523,7 @@ To use this command line, ask the user to modify the command line rules in the c
530
523
  return {
531
524
  error: `Maximum concurrent process limit reached (${ke} processes). Cannot start new process until existing processes complete. Use process-list to see active processes, or process-kill to terminate unnecessary processes.`
532
525
  };
533
- const d = Ir(), p = {
526
+ const d = $r(), p = {
534
527
  id: d,
535
528
  cwd: u,
536
529
  commandLine: e,
@@ -543,8 +536,8 @@ To use this command line, ask the user to modify the command line rules in the c
543
536
  const h = Cr(
544
537
  process.cwd(),
545
538
  u,
546
- r.envCleanup ?? "deleteServerPaths",
547
- r.env
539
+ t.envCleanup ?? "deleteServerPaths",
540
+ t.env
548
541
  ), g = tr(e, [], {
549
542
  shell: !0,
550
543
  cwd: u,
@@ -562,17 +555,17 @@ To use this command line, ask the user to modify the command line rules in the c
562
555
  p.isRunning = !1, p.endTime = /* @__PURE__ */ new Date(), p.error = w.message, console.error(`Process ${d} error:`, w.message);
563
556
  }), n != null ? wt(
564
557
  { id: d, waitTime: n, autoKill: i, outputLimit: a },
565
- r,
558
+ t,
566
559
  s
567
- ) : ye({ id: d, outputLimit: a }, r, s);
560
+ ) : ye({ id: d, outputLimit: a }, t, s);
568
561
  } catch (h) {
569
562
  return p.isRunning = !1, p.endTime = /* @__PURE__ */ new Date(), p.error = h instanceof Error ? h.message : "Unknown error", { error: p.error };
570
563
  }
571
564
  }
572
- function zr(t, r) {
573
- const s = r.commandLineRules.map((o) => `${o.rule.toUpperCase()}: ${o.regexp} (${o.note})`).join(`
565
+ function zr(r, t) {
566
+ const s = t.commandLineRules.map((o) => `${o.rule.toUpperCase()}: ${o.regexp} (${o.note})`).join(`
574
567
  `);
575
- t(
568
+ r(
576
569
  "process-run",
577
570
  {
578
571
  title: "Execute Command Line on Host Machine",
@@ -581,7 +574,7 @@ ${s}`,
581
574
  inputSchema: yt.shape
582
575
  },
583
576
  async (o, e) => {
584
- const n = await Ar(o, r, e);
577
+ const n = await Ar(o, t, e);
585
578
  if (!("output" in n))
586
579
  return `Method: process-run(${JSON.stringify(o)})
587
580
  ❌ Error: ${n.error}`;
@@ -608,11 +601,11 @@ const bt = m.object({
608
601
  'Specific process data fields to include in the response. If omitted, returns all available fields. Fields id, isRunning, and commandLine are always included. Available fields: id, cwd, commandLine, pid, startTime, endTime, exitCode, isRunning, output, error. Examples: ["id", "commandLine", "isRunning"] for minimal info, ["id", "output", "exitCode"] for execution results'
609
602
  )
610
603
  });
611
- async function Ur(t, r) {
604
+ async function Ur(r, t) {
612
605
  ge();
613
606
  let s;
614
607
  try {
615
- s = bt.parse(t);
608
+ s = bt.parse(r);
616
609
  } catch (l) {
617
610
  return {
618
611
  error: F(l)
@@ -631,7 +624,7 @@ async function Ur(t, r) {
631
624
  return n && (a = a.filter((l) => l.isRunning)), { processes: a.map((l) => {
632
625
  let u = {
633
626
  id: l.id,
634
- cwd: k.relative(r.workingDir || "", l.cwd),
627
+ cwd: k.relative(t.workingDir || "", l.cwd),
635
628
  commandLine: l.commandLine,
636
629
  pid: l.pid,
637
630
  startTime: l.startTime.toISOString().replace(/[TZ]/g, " ").trim(),
@@ -651,8 +644,8 @@ async function Ur(t, r) {
651
644
  return u;
652
645
  }) };
653
646
  }
654
- function jr(t, r) {
655
- t(
647
+ function jr(r, t) {
648
+ r(
656
649
  "process-list",
657
650
  {
658
651
  title: "List Host Machine Processes",
@@ -660,7 +653,7 @@ function jr(t, r) {
660
653
  inputSchema: bt.shape
661
654
  },
662
655
  async (s) => {
663
- const o = await Ur(s, r);
656
+ const o = await Ur(s, t);
664
657
  if (o.error != null)
665
658
  return `Method: process-list(${JSON.stringify(s)})
666
659
  ❌ Error: ${o.error}`;
@@ -679,16 +672,16 @@ const St = m.object({
679
672
  "Process ID of the process to terminate. Get process IDs using process-list. The process must be currently running. Examples: 1, 42, 123"
680
673
  )
681
674
  });
682
- function qr(t) {
683
- let r;
675
+ function qr(r) {
676
+ let t;
684
677
  try {
685
- r = St.parse(t);
678
+ t = St.parse(r);
686
679
  } catch (e) {
687
680
  return {
688
681
  error: F(e)
689
682
  };
690
683
  }
691
- const { id: s } = r, o = Y.get(s);
684
+ const { id: s } = t, o = Y.get(s);
692
685
  if (!o)
693
686
  return {
694
687
  error: `Process ${s} not found. The process may have already completed, been cleaned up after 30 minutes, or the ID may be incorrect. Use process-list to see available processes and their current status.`
@@ -709,8 +702,8 @@ function qr(t) {
709
702
  };
710
703
  }
711
704
  }
712
- function _r(t, r) {
713
- t(
705
+ function _r(r, t) {
706
+ r(
714
707
  "process-kill",
715
708
  {
716
709
  title: "Kill Host Machine Process",
@@ -725,31 +718,31 @@ ${JSON.stringify(o, null, 2)}`;
725
718
  }
726
719
  );
727
720
  }
728
- function Gr(t, r) {
729
- Mr(), r.run && zr(t, r), r.status && Br(t, r), r.wait && Lr(t, r), r.list && jr(t, r), r.kill && _r(t);
730
- const s = r.commandLineRules?.map(
721
+ function Gr(r, t) {
722
+ Mr(), t.run && zr(r, t), t.status && Br(r, t), t.wait && Lr(r, t), t.list && jr(r, t), t.kill && _r(r);
723
+ const s = t.commandLineRules?.map(
731
724
  (o) => `${o.rule.toUpperCase()}: ${o.regexp} (${o.note})`
732
725
  ) || [];
733
726
  console.log(
734
727
  `Process manager:
735
- - Working directory: ${k.resolve(r.workingDir || "")}
736
- - Command line rules: ${r.commandLineRules?.length || 0} rules configured:
728
+ - Working directory: ${k.resolve(t.workingDir || "")}
729
+ - Command line rules: ${t.commandLineRules?.length || 0} rules configured:
737
730
  ${s.map((o) => `- ${o}`).join(`
738
731
  `)}
739
732
  `
740
733
  );
741
734
  }
742
- function Jr(t, r) {
735
+ function Jr(r, t) {
743
736
  return function(o, e, n) {
744
737
  const i = async (...a) => {
745
738
  await ie({
746
- logFilePath: r.logFilePath,
739
+ logFilePath: t.logFilePath,
747
740
  message: "REQUEST",
748
741
  data: { name: o, args: a }
749
742
  });
750
743
  const c = await n(...a);
751
744
  return await ie({
752
- logFilePath: r.logFilePath,
745
+ logFilePath: t.logFilePath,
753
746
  message: "RESPONSE",
754
747
  data: c
755
748
  }), {
@@ -761,35 +754,35 @@ function Jr(t, r) {
761
754
  ]
762
755
  };
763
756
  };
764
- return t.registerTool(
757
+ return r.registerTool(
765
758
  o,
766
759
  e,
767
760
  i
768
761
  );
769
762
  };
770
763
  }
771
- function Wr(t) {
772
- return t.match(/^[/\\]?[^/\\]+/)[0];
764
+ function Wr(r) {
765
+ return r.match(/^[/\\]?[^/\\]+/)[0];
773
766
  }
774
- function Kr(t, r) {
775
- return Wr(t) + "|" + r.ino;
767
+ function Kr(r, t) {
768
+ return Wr(r) + "|" + t.ino;
776
769
  }
777
- function Hr(t) {
778
- return t.endsWith(":") && (t += "/"), k.resolve(t);
770
+ function Hr(r) {
771
+ return r.endsWith(":") && (r += "/"), k.resolve(r);
779
772
  }
780
773
  const Se = new rr(ir.cpus().length);
781
- function Be(t, r) {
782
- t.totalSize += r.totalSize, t.maxFileDateModified = Math.max(
783
- t.maxFileDateModified,
784
- r.maxFileDateModified
785
- ), t.countFiles += r.countFiles, t.countDirs += r.countDirs, t.countLinks += r.countLinks;
786
- }
787
- const Qr = function(r) {
788
- return r.code === "ENOENT";
774
+ function Be(r, t) {
775
+ r.totalSize += t.totalSize, r.maxFileDateModified = Math.max(
776
+ r.maxFileDateModified,
777
+ t.maxFileDateModified
778
+ ), r.countFiles += t.countFiles, r.countDirs += t.countDirs, r.countLinks += t.countLinks;
779
+ }
780
+ const Qr = function(t) {
781
+ return t.code === "ENOENT";
789
782
  };
790
- function xt(t) {
791
- const r = t.paths;
792
- if (!r || r.length === 0)
783
+ function xt(r) {
784
+ const t = r.paths;
785
+ if (!t || t.length === 0)
793
786
  return Promise.resolve({
794
787
  totalSize: 0,
795
788
  maxFileDateModified: 0,
@@ -797,7 +790,7 @@ function xt(t) {
797
790
  countDirs: 0,
798
791
  countLinks: 0
799
792
  });
800
- const s = t.level ?? 0, o = t.walkedIds ?? /* @__PURE__ */ new Set(), e = t.abortSignal, n = t.pool ?? Se, i = t.handleError, a = t.priority ?? X(0), c = t.walkLinks ?? !1, l = t.log, u = t.handlePath, f = t.matchPath;
793
+ const s = r.level ?? 0, o = r.walkedIds ?? /* @__PURE__ */ new Set(), e = r.abortSignal, n = r.pool ?? Se, i = r.handleError, a = r.priority ?? X(0), c = r.walkLinks ?? !1, l = r.log, u = r.handlePath, f = r.matchPath;
801
794
  async function d(h) {
802
795
  if (!(i && await i(h)) && !Qr(h))
803
796
  throw h;
@@ -813,20 +806,20 @@ function xt(t) {
813
806
  countDirs: 0,
814
807
  countLinks: 0
815
808
  };
816
- function w($, T) {
809
+ function w(I, T) {
817
810
  if (p(T.totalSize)) {
818
- const S = `${T.totalSize.toLocaleString("en-US").replace(/,/g, " ").padStart(19)}: ${$}`;
811
+ const S = `${T.totalSize.toLocaleString("en-US").replace(/,/g, " ").padStart(19)}: ${I}`;
819
812
  l?.handleLog ? l.handleLog(S) : console.log(S);
820
813
  }
821
814
  }
822
- async function M($, T, x, S) {
815
+ async function M(I, T, x, S) {
823
816
  return u ? await V({
824
817
  pool: n,
825
818
  func: async () => {
826
819
  try {
827
820
  return await u({
828
821
  level: s,
829
- path: $,
822
+ path: I,
830
823
  stat: T,
831
824
  itemStat: x,
832
825
  totalStat: y,
@@ -841,18 +834,18 @@ function xt(t) {
841
834
  abortSignal: g
842
835
  }) : !0;
843
836
  }
844
- async function E($, T, x, S) {
845
- S || (S = $);
837
+ async function E(I, T, x, S) {
838
+ S || (S = I);
846
839
  const v = await V({
847
840
  pool: n,
848
- func: () => j.promises.lstat($).catch(d),
841
+ func: () => j.promises.lstat(I).catch(d),
849
842
  count: 1,
850
843
  priority: X(T, X(1, a)),
851
844
  abortSignal: g
852
845
  });
853
846
  if (!v || !x && v.isFile())
854
847
  return null;
855
- const P = Kr($, v);
848
+ const P = Kr(I, v);
856
849
  if (o.has(P))
857
850
  return null;
858
851
  o.add(P);
@@ -863,7 +856,7 @@ function xt(t) {
863
856
  countDirs: 0,
864
857
  countLinks: 0
865
858
  };
866
- const I = X(
859
+ const $ = X(
867
860
  T,
868
861
  X(v.isDirectory() ? 2 : 3, a)
869
862
  );
@@ -871,9 +864,9 @@ function xt(t) {
871
864
  if (c) {
872
865
  const C = await V({
873
866
  pool: n,
874
- func: () => j.promises.readlink($).catch(d).then((N) => N ?? null),
867
+ func: () => j.promises.readlink(I).catch(d).then((N) => N ?? null),
875
868
  count: 1,
876
- priority: I,
869
+ priority: $,
877
870
  abortSignal: g
878
871
  });
879
872
  if (C) {
@@ -890,12 +883,12 @@ function xt(t) {
890
883
  S,
891
884
  v,
892
885
  O,
893
- I
886
+ $
894
887
  ) && (Be(y, O), w(S, O))), O;
895
888
  } else if (v.isDirectory()) {
896
889
  const C = await V({
897
890
  pool: n,
898
- func: () => j.promises.readdir($).catch(d),
891
+ func: () => j.promises.readdir(I).catch(d),
899
892
  count: 1,
900
893
  priority: a,
901
894
  abortSignal: g
@@ -904,10 +897,10 @@ function xt(t) {
904
897
  for (let N = 0, R = C.length; N < R; N++)
905
898
  C[N] = k.join(S, C[N]);
906
899
  O = await xt({
907
- ...t,
900
+ ...r,
908
901
  paths: C,
909
902
  abortSignal: g,
910
- priority: I,
903
+ priority: $,
911
904
  level: s + 1,
912
905
  walkedIds: o
913
906
  });
@@ -917,48 +910,48 @@ function xt(t) {
917
910
  S,
918
911
  v,
919
912
  O,
920
- I
913
+ $
921
914
  ) && (Be(y, O), w(S, O))), O;
922
915
  }
923
916
  const b = [];
924
- for (let $ = 0, T = r.length; $ < T; $++) {
925
- const x = Hr(r[$]), S = f ? f(x) : !0;
926
- S !== !1 && b.push(E(x, $, S));
917
+ for (let I = 0, T = t.length; I < T; I++) {
918
+ const x = Hr(t[I]), S = f ? f(x) : !0;
919
+ S !== !1 && b.push(E(x, I, S));
927
920
  }
928
921
  return await Promise.all(b), y;
929
922
  });
930
923
  }
931
- function $t(t) {
932
- return xt(t);
924
+ function It(r) {
925
+ return xt(r);
933
926
  }
934
- function Yr(t, r) {
935
- if (!r || r === ".")
936
- return t;
937
- const s = t.startsWith("^");
938
- s && (t = t.substring(1));
939
- const o = t.startsWith("!");
940
- return o && (t = t.substring(1)), t.startsWith("/") ? (r.endsWith("/") && (r = r.substring(0, r.length - 1)), t = r + t) : (r.endsWith("/") || (r += "/"), t.startsWith("./") ? t = r + t.substring(2) : t.startsWith("../") ? t = r + t : (r.startsWith("..") && (r = ""), t.startsWith("**") ? t = r + t : t = r + "**/" + t)), t = H(k.normalize(t)), o && (t = "!" + t), s && (t = "^" + t), t;
927
+ function Yr(r, t) {
928
+ if (!t || t === ".")
929
+ return r;
930
+ const s = r.startsWith("^");
931
+ s && (r = r.substring(1));
932
+ const o = r.startsWith("!");
933
+ return o && (r = r.substring(1)), r.startsWith("/") ? (t.endsWith("/") && (t = t.substring(0, t.length - 1)), r = t + r) : (t.endsWith("/") || (t += "/"), r.startsWith("./") ? r = t + r.substring(2) : r.startsWith("../") ? r = t + r : (t.startsWith("..") && (t = ""), r.startsWith("**") ? r = t + r : r = t + "**/" + r)), r = H(k.normalize(r)), o && (r = "!" + r), s && (r = "^" + r), r;
941
934
  }
942
- function Vr(t) {
943
- const r = t.startsWith("!");
944
- return r && (t = t.substring(1)), t.startsWith("/") ? t = t.substring(1) : !t.startsWith("**") && !t.startsWith("../") && (t = `**/${t}`), r && (t = "!" + t), t;
935
+ function Vr(r) {
936
+ const t = r.startsWith("!");
937
+ return t && (r = r.substring(1)), !r.startsWith("/") && !r.startsWith("**") && !r.startsWith("../") && (r = `**/${r}`), t && (r = "!" + r), r;
945
938
  }
946
- function Le(t) {
947
- return "^" + t;
939
+ function Le(r) {
940
+ return "^" + r;
948
941
  }
949
- async function Zr(t) {
950
- const s = (await j.promises.readFile(t, "utf-8")).split(`
942
+ async function Zr(r) {
943
+ const s = (await j.promises.readFile(r, "utf-8")).split(`
951
944
  `), o = [];
952
945
  return s.forEach((e) => {
953
946
  e = e.trim(), !(!e || e.startsWith("#")) && o.push(e);
954
947
  }), o;
955
948
  }
956
- async function It(t) {
957
- const r = t.rootDir ?? ".", s = [];
958
- if (!t.globs?.length)
949
+ async function $t(r) {
950
+ const t = r.rootDir ?? ".", s = [];
951
+ if (!r.globs?.length)
959
952
  return s;
960
953
  const o = [];
961
- return t.globs.forEach((e) => {
954
+ return r.globs.forEach((e) => {
962
955
  e.value && (e.valueType === "file-contains-patterns" ? o.push(e) : e.valueType === "pattern" && s.push(e.exclude ? Le(e.value) : e.value));
963
956
  }), o.length && await Promise.all(
964
957
  o.map(async (e) => {
@@ -966,7 +959,7 @@ async function It(t) {
966
959
  pool: Se,
967
960
  count: 1,
968
961
  func: async () => {
969
- const n = k.resolve(r, e.value), i = await Zr(n), a = k.relative(r, k.dirname(n));
962
+ const n = k.resolve(t, e.value), i = await Zr(n), a = k.relative(t, k.dirname(n));
970
963
  i.forEach((c) => {
971
964
  c = Vr(c), c = Yr(c, a), s.push(e.exclude ? Le(c) : c);
972
965
  });
@@ -976,12 +969,12 @@ async function It(t) {
976
969
  ), s;
977
970
  }
978
971
  function Mt({
979
- globs: t,
980
- rootDir: r,
972
+ globs: r,
973
+ rootDir: t,
981
974
  noCase: s
982
975
  }) {
983
976
  const o = [];
984
- return t.forEach((e) => {
977
+ return r.forEach((e) => {
985
978
  e = H(e).trim();
986
979
  const n = e.startsWith("^");
987
980
  n && (e = e.substring(1).trim());
@@ -991,7 +984,7 @@ function Mt({
991
984
  `Invalid glob pattern: "${e}". The syntax '${e.substring(0, 2)}' is not supported. Valid glob patterns use: * (match any characters), ** (match any directories), ? (match single character), [abc] (character class), ! (negate pattern), ^ (exclude if included). Examples of valid patterns: "*.js", "src/**/*.ts", "!node_modules", "^dist". Avoid starting with '!' after '^' or multiple special prefixes.`
992
985
  );
993
986
  e.startsWith("/") && (e = "." + e);
994
- const a = H(r ? k.resolve(r, e) : e);
987
+ const a = H(t ? k.resolve(t, e) : e);
995
988
  if (!a)
996
989
  return;
997
990
  let c;
@@ -1023,61 +1016,61 @@ function Mt({
1023
1016
  return a ? !1 : i;
1024
1017
  };
1025
1018
  }
1026
- async function Xr(t) {
1027
- const r = t.rootDir ?? ".", s = [], o = {};
1028
- t.result.countFiles && (o.countFiles = 0), t.result.size && (o.size = 0);
1029
- const e = await It({
1030
- rootDir: r,
1031
- globs: t.globs
1019
+ async function Xr(r) {
1020
+ const t = r.rootDir ?? ".", s = [], o = {};
1021
+ r.result.countFiles && (o.countFiles = 0), r.result.size && (o.size = 0);
1022
+ const e = await $t({
1023
+ rootDir: t,
1024
+ globs: r.globs
1032
1025
  });
1033
- return await $t({
1034
- paths: [r],
1026
+ return await It({
1027
+ paths: [t],
1035
1028
  walkLinks: !0,
1036
1029
  matchPath: Mt({
1037
1030
  globs: e,
1038
- rootDir: r,
1031
+ rootDir: t,
1039
1032
  noCase: !0
1040
1033
  }),
1041
1034
  handlePath: async ({ path: n, stat: i, itemStat: a }) => {
1042
- const c = k.relative(r, n), l = i.isDirectory(), u = i.isFile();
1035
+ const c = k.relative(t, n), l = i.isDirectory(), u = i.isFile();
1043
1036
  if (!l && !u)
1044
1037
  return !0;
1045
1038
  const f = H(c || "."), d = l ? "dir" : "file", p = l ? a.maxFileDateModified || null : i.mtimeMs, h = l ? a.totalSize : i.size, g = l ? a.countFiles : null, y = {
1046
1039
  path: f,
1047
1040
  type: d
1048
1041
  };
1049
- if (t.result.dateModified && (y.dateModified = p), t.result.size && (y.size = h), t.result.countFiles && (y.countFiles = g), t.dateModified && p != null) {
1050
- const [w, M] = t.dateModified;
1042
+ if (r.result.dateModified && (y.dateModified = p), r.result.size && (y.size = h), r.result.countFiles && (y.countFiles = g), r.dateModified && p != null) {
1043
+ const [w, M] = r.dateModified;
1051
1044
  if (w != null && p < w || M != null && p > M)
1052
1045
  return !1;
1053
1046
  }
1054
- if (t.totalSize && h != null) {
1055
- const [w, M] = t.totalSize;
1047
+ if (r.totalSize && h != null) {
1048
+ const [w, M] = r.totalSize;
1056
1049
  if (w != null && h < w || M != null && h > M)
1057
1050
  return !1;
1058
1051
  }
1059
- return d === "file" && (o.countFiles = (o.countFiles ?? 0) + 1), d === "file" && h != null && (o.size = (o.size ?? 0) + h), p != null && (o.dateModified == null || p > o.dateModified) && (o.dateModified = p), l && !t.result.dirs || u && !t.result.files || s.push(y), !0;
1052
+ return d === "file" && (o.countFiles = (o.countFiles ?? 0) + 1), d === "file" && h != null && (o.size = (o.size ?? 0) + h), p != null && (o.dateModified == null || p > o.dateModified) && (o.dateModified = p), l && !r.result.dirs || u && !r.result.files || s.push(y), !0;
1060
1053
  }
1061
1054
  }), { items: s, totals: o };
1062
1055
  }
1063
1056
  const Ae = ["B", "KB", "MB", "GB", "TB"], ze = 1024;
1064
- function Ue(t) {
1065
- if (t == null) return "-";
1066
- let r = t ?? 0, s = 0;
1067
- for (; r >= ze && s < Ae.length - 1; )
1068
- r /= ze, s++;
1069
- return `${s === 0 ? r.toString() : r.toFixed(2)}${Ae[s]}`;
1070
- }
1071
- function je(t) {
1072
- const s = Date.now() - t;
1057
+ function Ue(r) {
1058
+ if (r == null) return "-";
1059
+ let t = r ?? 0, s = 0;
1060
+ for (; t >= ze && s < Ae.length - 1; )
1061
+ t /= ze, s++;
1062
+ return `${s === 0 ? t.toString() : t.toFixed(2)}${Ae[s]}`;
1063
+ }
1064
+ function je(r) {
1065
+ const s = Date.now() - r;
1073
1066
  if (s < 0) return "0s";
1074
1067
  const o = Math.floor(s / 1e3), e = Math.floor(o / 60), n = Math.floor(e / 60), i = Math.floor(n / 24), a = Math.floor(i / 7), c = Math.floor(i / 30), l = Math.floor(i / 365);
1075
1068
  return l > 0 ? `${l}Y` : c > 0 ? `${c}M` : a > 0 ? `${a}w` : i > 0 ? `${i}d` : n > 0 ? `${n}h` : e > 0 ? `${e}m` : `${o}s`;
1076
1069
  }
1077
- function es(t, r) {
1078
- return r?.length ? [...t].sort((s, o) => {
1079
- for (let e = 0, n = r.length; e < n; e++) {
1080
- const i = r[e];
1070
+ function es(r, t) {
1071
+ return t?.length ? [...r].sort((s, o) => {
1072
+ for (let e = 0, n = t.length; e < n; e++) {
1073
+ const i = t[e];
1081
1074
  let a, c;
1082
1075
  switch (i.field) {
1083
1076
  case "type":
@@ -1108,10 +1101,10 @@ function es(t, r) {
1108
1101
  return i.desc ? -l : l;
1109
1102
  }
1110
1103
  return 0;
1111
- }) : t;
1104
+ }) : r;
1112
1105
  }
1113
- function ts(t, r) {
1114
- const s = es(t.items, r.sort ?? []), o = r.fields && r.fields.length > 0 ? r.fields : [];
1106
+ function ts(r, t) {
1107
+ const s = es(r.items, t.sort ?? []), o = t.fields && t.fields.length > 0 ? t.fields : [];
1115
1108
  let e = "";
1116
1109
  if (s.length > 0 && o.length > 0) {
1117
1110
  for (let n = 0, i = o.length; n < i; n++) {
@@ -1164,24 +1157,24 @@ function ts(t, r) {
1164
1157
  e.length > 0 && (e += `
1165
1158
  ---
1166
1159
  `);
1167
- const n = Ue(t.totals.size ?? 0), i = t.totals.dateModified ? `, last modified ${je(t.totals.dateModified)} ago` : "";
1168
- e += `Totals: ${t.totals.countFiles ?? 0} files in dirs, ${n}${i}`;
1160
+ const n = Ue(r.totals.size ?? 0), i = r.totals.dateModified ? `, last modified ${je(r.totals.dateModified)} ago` : "";
1161
+ e += `Totals: ${r.totals.countFiles ?? 0} files in dirs, ${n}${i}`;
1169
1162
  }
1170
1163
  return e;
1171
1164
  }
1172
- const rs = "5.0.0", ss = {
1165
+ const rs = "5.0.2", ss = {
1173
1166
  version: rs
1174
1167
  }, Wo = "Project Tools", Ko = "project-tools", Ho = ss.version, Qo = "d00f70240703039df14c76176a055bce6b5484d2b552ba2c89820f03b8e5e60d", qe = 25e3;
1175
- function _e(t) {
1176
- const r = t.match(
1168
+ function _e(r) {
1169
+ const t = r.match(
1177
1170
  /^\s*(\d+(?:\.\d+)?)\s*([smhdwMY]|sec(onds?)?|min(utes?)?|hours?|days?|weeks?|months?|years?)\s*$/i
1178
1171
  );
1179
- if (!r)
1172
+ if (!t)
1180
1173
  throw new Error(
1181
- `Invalid time ago format: "${t}". Must be a number followed by a time unit. Valid units: s/sec/seconds (seconds), m/min/minutes (minutes), h/hours (hours), d/days (days), w/weeks (weeks), M/months (months), Y/years (years). Examples: "30s", "0.5h", "1.5d", "7d", "3w", "6M", "1Y". Format is case-insensitive except M (months) must be uppercase to distinguish from m (minutes).`
1174
+ `Invalid time ago format: "${r}". Must be a number followed by a time unit. Valid units: s/sec/seconds (seconds), m/min/minutes (minutes), h/hours (hours), d/days (days), w/weeks (weeks), M/months (months), Y/years (years). Examples: "30s", "0.5h", "1.5d", "7d", "3w", "6M", "1Y". Format is case-insensitive except M (months) must be uppercase to distinguish from m (minutes).`
1182
1175
  );
1183
- const s = parseFloat(r[1]);
1184
- let o = r[2];
1176
+ const s = parseFloat(t[1]);
1177
+ let o = t[2];
1185
1178
  switch (o !== "M" && (o = o.toLowerCase(), o.startsWith("month") ? o = "M" : o.length > 1 && (o = o[0])), o) {
1186
1179
  case "s":
1187
1180
  return s * 1e3;
@@ -1203,13 +1196,13 @@ function _e(t) {
1203
1196
  );
1204
1197
  }
1205
1198
  }
1206
- function Ge(t) {
1207
- const r = t.match(/^\s*(\d+(?:\.\d+)?)\s*(B|KB|MB|GB|TB)\s*$/i);
1208
- if (!r)
1199
+ function Ge(r) {
1200
+ const t = r.match(/^\s*(\d+(?:\.\d+)?)\s*(B|KB|MB|GB|TB)\s*$/i);
1201
+ if (!t)
1209
1202
  throw new Error(
1210
- `Invalid size format: "${t}". Must be a number (integer or decimal) followed by a size unit. Valid units: B (bytes), KB (kilobytes), MB (megabytes), GB (gigabytes), TB (terabytes). Uses binary units (1024-based). Examples: "1B", "2.5KB", "100MB", "1.2GB", "0.5TB". Units are case-insensitive.`
1203
+ `Invalid size format: "${r}". Must be a number (integer or decimal) followed by a size unit. Valid units: B (bytes), KB (kilobytes), MB (megabytes), GB (gigabytes), TB (terabytes). Uses binary units (1024-based). Examples: "1B", "2.5KB", "100MB", "1.2GB", "0.5TB". Units are case-insensitive.`
1211
1204
  );
1212
- const s = parseFloat(r[1]), o = r[2].toUpperCase();
1205
+ const s = parseFloat(t[1]), o = t[2].toUpperCase();
1213
1206
  switch (o) {
1214
1207
  case "B":
1215
1208
  return s;
@@ -1266,10 +1259,10 @@ const Tt = m.object({
1266
1259
  'Filter files/directories with total size at most this large. Only items with size <= this value will be included. For directories, uses total size of all contents. Format: number + unit (B/KB/MB/GB/TB). Examples: "1MB" (up to 1 megabyte), "500KB" (up to 500 kilobytes), "10GB" (up to 10 gigabytes). Combine with minTotalSize for size ranges'
1267
1260
  )
1268
1261
  });
1269
- async function os(t, r) {
1262
+ async function os(r, t) {
1270
1263
  let s;
1271
1264
  try {
1272
- s = Tt.parse(t);
1265
+ s = Tt.parse(r);
1273
1266
  } catch (y) {
1274
1267
  return {
1275
1268
  error: F(y)
@@ -1300,7 +1293,7 @@ async function os(t, r) {
1300
1293
  }) ?? null;
1301
1294
  (!d || d.length === 0) && (d = [{ field: "path", desc: !1 }]);
1302
1295
  const p = d?.map((y) => y.field) || [], h = be(
1303
- r.workingDir,
1296
+ t.workingDir,
1304
1297
  s.relativeRootDir
1305
1298
  );
1306
1299
  if ("error" in h)
@@ -1320,14 +1313,14 @@ async function os(t, r) {
1320
1313
  value: S,
1321
1314
  valueType: "pattern",
1322
1315
  exclude: !1
1323
- })) : [{ value: "**", valueType: "pattern", exclude: !1 }], w = r.globsExclude || [], M = [...y, ...w], E = {
1316
+ })) : [{ value: "**", valueType: "pattern", exclude: !1 }], w = t.globsExclude || [], M = [...y, ...w], E = {
1324
1317
  files: e ?? !1,
1325
1318
  dirs: n ?? !1,
1326
1319
  dateModified: f.includes("dateModified") || p.includes("dateModified"),
1327
1320
  size: f.includes("size") || p.includes("size"),
1328
1321
  countFiles: f.includes("countFiles") || p.includes("countFiles")
1329
1322
  };
1330
- let b = null, $ = null;
1323
+ let b = null, I = null;
1331
1324
  if (a || c)
1332
1325
  try {
1333
1326
  const S = Date.now(), v = c ? S - _e(c) : null, P = a ? S - _e(a) : null;
@@ -1340,7 +1333,7 @@ async function os(t, r) {
1340
1333
  if (l || u)
1341
1334
  try {
1342
1335
  const S = l ? Ge(l) : null, v = u ? Ge(u) : null;
1343
- $ = [S, v];
1336
+ I = [S, v];
1344
1337
  } catch (S) {
1345
1338
  return {
1346
1339
  error: S instanceof Error ? S.message : "Unknown error parsing size filter"
@@ -1351,7 +1344,7 @@ async function os(t, r) {
1351
1344
  globs: M,
1352
1345
  result: E,
1353
1346
  dateModified: b,
1354
- totalSize: $
1347
+ totalSize: I
1355
1348
  });
1356
1349
  return T.items.length > qe ? {
1357
1350
  error: `Number of paths (${T.items.length}) exceeds maximum allowed (${qe}). Consider using more specific glob patterns or filters to reduce the result set.`
@@ -1366,8 +1359,8 @@ async function os(t, r) {
1366
1359
  return { error: y instanceof Error ? y.message : "Unknown error" };
1367
1360
  }
1368
1361
  }
1369
- function ns(t, r) {
1370
- t(
1362
+ function ns(r, t) {
1363
+ r(
1371
1364
  "fs-list",
1372
1365
  {
1373
1366
  title: "List Files and Directories",
@@ -1375,7 +1368,7 @@ function ns(t, r) {
1375
1368
  inputSchema: Tt.shape
1376
1369
  },
1377
1370
  async (s) => {
1378
- const o = await os(s, r);
1371
+ const o = await os(s, t);
1379
1372
  return o.error ? `Method: fs-list(${JSON.stringify(s)})
1380
1373
  ❌ Error: ${o.error}` : `Method: fs-list(${JSON.stringify(s)})
1381
1374
  ${o.output || JSON.stringify(o, null, 2)}`;
@@ -1387,23 +1380,23 @@ let is = 0;
1387
1380
  function as() {
1388
1381
  return `${++is}-${Math.random().toString(36).slice(2)}`;
1389
1382
  }
1390
- function Z(t) {
1391
- return ue.has(t) || ue.set(t, {
1383
+ function Z(r) {
1384
+ return ue.has(r) || ue.set(r, {
1392
1385
  fsSnapshotQueries: /* @__PURE__ */ new Map(),
1393
1386
  fsSnapshots: /* @__PURE__ */ new Map(),
1394
1387
  preparedReplace: null
1395
- }), ue.get(t);
1388
+ }), ue.get(r);
1396
1389
  }
1397
- function Je(t) {
1398
- const r = t.match(
1390
+ function Je(r) {
1391
+ const t = r.match(
1399
1392
  /^\s*(\d+(?:\.\d+)?)\s*([smhdwMY]|sec(onds?)?|min(utes?)?|hours?|days?|weeks?|months?|years?)\s*$/i
1400
1393
  );
1401
- if (!r)
1394
+ if (!t)
1402
1395
  throw new Error(
1403
- `Invalid time ago format: "${t}". Must be a number followed by a time unit. Valid units: s/sec/seconds (seconds), m/min/minutes (minutes), h/hours (hours), d/days (days), w/weeks (weeks), M/months (months), Y/years (years). Examples: "30s", "0.5h", "1.5d", "7d", "3w", "6M", "1Y". Format is case-insensitive except M (months) must be uppercase to distinguish from m (minutes).`
1396
+ `Invalid time ago format: "${r}". Must be a number followed by a time unit. Valid units: s/sec/seconds (seconds), m/min/minutes (minutes), h/hours (hours), d/days (days), w/weeks (weeks), M/months (months), Y/years (years). Examples: "30s", "0.5h", "1.5d", "7d", "3w", "6M", "1Y". Format is case-insensitive except M (months) must be uppercase to distinguish from m (minutes).`
1404
1397
  );
1405
- const s = parseFloat(r[1]);
1406
- let o = r[2];
1398
+ const s = parseFloat(t[1]);
1399
+ let o = t[2];
1407
1400
  switch (o !== "M" && (o = o.toLowerCase(), o.startsWith("month") ? o = "M" : o.length > 1 && (o = o[0])), o) {
1408
1401
  case "s":
1409
1402
  return s * 1e3;
@@ -1425,13 +1418,13 @@ function Je(t) {
1425
1418
  );
1426
1419
  }
1427
1420
  }
1428
- function We(t) {
1429
- const r = t.match(/^\s*(\d+(?:\.\d+)?)\s*(B|KB|MB|GB|TB)\s*$/i);
1430
- if (!r)
1421
+ function We(r) {
1422
+ const t = r.match(/^\s*(\d+(?:\.\d+)?)\s*(B|KB|MB|GB|TB)\s*$/i);
1423
+ if (!t)
1431
1424
  throw new Error(
1432
- `Invalid size format: "${t}". Must be a number (integer or decimal) followed by a size unit. Valid units: B (bytes), KB (kilobytes), MB (megabytes), GB (gigabytes), TB (terabytes). Uses binary units (1024-based). Examples: "1B", "2.5KB", "100MB", "1.2GB", "0.5TB". Units are case-insensitive.`
1425
+ `Invalid size format: "${r}". Must be a number (integer or decimal) followed by a size unit. Valid units: B (bytes), KB (kilobytes), MB (megabytes), GB (gigabytes), TB (terabytes). Uses binary units (1024-based). Examples: "1B", "2.5KB", "100MB", "1.2GB", "0.5TB". Units are case-insensitive.`
1433
1426
  );
1434
- const s = parseFloat(r[1]), o = r[2].toUpperCase();
1427
+ const s = parseFloat(t[1]), o = t[2].toUpperCase();
1435
1428
  switch (o) {
1436
1429
  case "B":
1437
1430
  return s;
@@ -1484,16 +1477,16 @@ const xe = m.object({
1484
1477
  "countMatched",
1485
1478
  "size",
1486
1479
  "dateModified"
1487
- ].map((t, r) => [t, r])
1480
+ ].map((r, t) => [r, t])
1488
1481
  );
1489
- function ls(t, r) {
1490
- const s = Ke.get(t) ?? 1 / 0, o = Ke.get(r) ?? 1 / 0;
1482
+ function ls(r, t) {
1483
+ const s = Ke.get(r) ?? 1 / 0, o = Ke.get(t) ?? 1 / 0;
1491
1484
  return s > o ? 1 : s < o ? -1 : 0;
1492
1485
  }
1493
- async function Ct(t, r, s) {
1486
+ async function Ct(r, t, s) {
1494
1487
  let o;
1495
1488
  try {
1496
- o = xe.parse(t);
1489
+ o = xe.parse(r);
1497
1490
  } catch (h) {
1498
1491
  return {
1499
1492
  error: F(h)
@@ -1513,7 +1506,7 @@ async function Ct(t, r, s) {
1513
1506
  error: "Session ID is required"
1514
1507
  };
1515
1508
  const f = Z(s.sessionId), d = be(
1516
- r.workingDir,
1509
+ t.workingDir,
1517
1510
  o.relativeRootDir
1518
1511
  );
1519
1512
  if ("error" in d)
@@ -1535,7 +1528,7 @@ async function Ct(t, r, s) {
1535
1528
  value: x,
1536
1529
  valueType: "pattern",
1537
1530
  exclude: !1
1538
- })) : [{ value: "**", valueType: "pattern", exclude: !1 }], y = r.globsExclude || [], w = [...g, ...y];
1531
+ })) : [{ value: "**", valueType: "pattern", exclude: !1 }], y = t.globsExclude || [], w = [...g, ...y];
1539
1532
  let M = null, E = null;
1540
1533
  if (a || c)
1541
1534
  try {
@@ -1555,12 +1548,12 @@ async function Ct(t, r, s) {
1555
1548
  error: x instanceof Error ? x.message : "Unknown error parsing size filter"
1556
1549
  };
1557
1550
  }
1558
- const b = i ? i.includes("file") : !0, $ = i ? i.includes("dir") : !0, T = {
1551
+ const b = i ? i.includes("file") : !0, I = i ? i.includes("dir") : !0, T = {
1559
1552
  name: e,
1560
1553
  rootDir: p,
1561
1554
  globs: w,
1562
1555
  matchFiles: b,
1563
- matchDirs: $,
1556
+ matchDirs: I,
1564
1557
  dateModified: M,
1565
1558
  totalSize: E,
1566
1559
  fields: h
@@ -1574,8 +1567,8 @@ async function Ct(t, r, s) {
1574
1567
  };
1575
1568
  }
1576
1569
  }
1577
- function cs(t, r) {
1578
- t(
1570
+ function cs(r, t) {
1571
+ r(
1579
1572
  "fs-snapshot-query-create",
1580
1573
  {
1581
1574
  title: "Create Filesystem Snapshot Query",
@@ -1583,21 +1576,21 @@ function cs(t, r) {
1583
1576
  inputSchema: xe.shape
1584
1577
  },
1585
1578
  async (s, o) => {
1586
- const e = await Ct(s, r, o);
1579
+ const e = await Ct(s, t, o);
1587
1580
  return e.error != null ? `Method: fs-snapshot-query-create(${JSON.stringify(s)})
1588
1581
  ❌ Error: ${e.error}` : `Method: fs-snapshot-query-create(${JSON.stringify(s)})
1589
1582
  ✅ Filesystem snapshot query "${e.snapshotQuery.name}" created successfully`;
1590
1583
  }
1591
1584
  );
1592
1585
  }
1593
- function le(t) {
1594
- const { idToNode: r, idToChildIds: s } = t, o = r.get(null);
1586
+ function le(r) {
1587
+ const { idToNode: t, idToChildIds: s } = r, o = t.get(null);
1595
1588
  if (o == null)
1596
1589
  throw new Error(
1597
1590
  "Impossible behavior: root node (id: null) not found in idToNode"
1598
1591
  );
1599
1592
  const e = /* @__PURE__ */ new Map();
1600
- return r.forEach((n, i) => {
1593
+ return t.forEach((n, i) => {
1601
1594
  if (n != null) {
1602
1595
  if (e.has(n)) {
1603
1596
  const a = e.get(n);
@@ -1609,18 +1602,18 @@ function le(t) {
1609
1602
  }
1610
1603
  }), {
1611
1604
  root: o,
1612
- getNode: (n) => r.get(n) ?? null,
1605
+ getNode: (n) => t.get(n) ?? null,
1613
1606
  getId: (n) => e.get(n) ?? null,
1614
1607
  getChilds: (n) => {
1615
1608
  let i = e.get(n);
1616
1609
  if (i == null)
1617
- if (n === r.get(null))
1610
+ if (n === t.get(null))
1618
1611
  i = null;
1619
1612
  else
1620
1613
  throw new Error("Impossible behavior: node not found in idToNode");
1621
1614
  const a = s.get(i);
1622
1615
  return a == null ? null : a.map((c) => {
1623
- const l = r.get(c);
1616
+ const l = t.get(c);
1624
1617
  if (l == null)
1625
1618
  throw new Error(
1626
1619
  `Child node with id '${c}' not found in idToNode`
@@ -1630,22 +1623,22 @@ function le(t) {
1630
1623
  }
1631
1624
  };
1632
1625
  }
1633
- function vt(t, r, s) {
1626
+ function vt(r, t, s) {
1634
1627
  let o = null;
1635
- for (let e = 0, n = r.length; e < n; e++) {
1636
- const i = r[e], a = t(i), c = a == null ? null : vt(t, a, s), l = s(i, c);
1628
+ for (let e = 0, n = t.length; e < n; e++) {
1629
+ const i = t[e], a = r(i), c = a == null ? null : vt(r, a, s), l = s(i, c);
1637
1630
  l != null && (o == null && (o = []), o.push(l));
1638
1631
  }
1639
1632
  return o;
1640
1633
  }
1641
- function Et(t) {
1642
- const { getId: r, getChilds: s, rootNodes: o, createSnapshotNode: e } = t, n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), c = vt(
1634
+ function Et(r) {
1635
+ const { getId: t, getChilds: s, rootNodes: o, createSnapshotNode: e } = r, n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), c = vt(
1643
1636
  s,
1644
1637
  o,
1645
1638
  (u, f) => {
1646
1639
  const d = e(u, f);
1647
1640
  if (u != null && d != null) {
1648
- const p = r(u);
1641
+ const p = t(u);
1649
1642
  n.set(p, d), i.set(d, p);
1650
1643
  }
1651
1644
  return d != null && f != null && a.set(
@@ -1664,11 +1657,11 @@ function Et(t) {
1664
1657
  idToChildIds: a
1665
1658
  };
1666
1659
  }
1667
- function me(t) {
1668
- return t = t != null ? H(t).replace(/\/$/, "") : null, !t || t === "." ? null : t;
1660
+ function me(r) {
1661
+ return r = r != null ? H(r).replace(/\/$/, "") : null, !r || r === "." ? null : r;
1669
1662
  }
1670
- async function us(t) {
1671
- const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), o = k.resolve(t.rootDir || "."), n = {
1663
+ async function us(r) {
1664
+ const t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), o = k.resolve(r.rootDir || "."), n = {
1672
1665
  path: ".",
1673
1666
  name: k.basename(o),
1674
1667
  type: "dir",
@@ -1676,12 +1669,12 @@ async function us(t) {
1676
1669
  dateModified: null,
1677
1670
  size: 0
1678
1671
  };
1679
- r.set(null, n);
1680
- const i = await It({
1672
+ t.set(null, n);
1673
+ const i = await $t({
1681
1674
  rootDir: o,
1682
- globs: t.globs
1675
+ globs: r.globs
1683
1676
  });
1684
- return await $t({
1677
+ return await It({
1685
1678
  paths: [o],
1686
1679
  walkLinks: !0,
1687
1680
  matchPath: Mt({
@@ -1695,13 +1688,13 @@ async function us(t) {
1695
1688
  return !0;
1696
1689
  const p = me(u || "."), h = f ? "dir" : "file", g = f ? null : c.mtimeMs, y = c.size;
1697
1690
  let w = !0;
1698
- if (d && !t.matchFiles && (w = !1), f && !t.matchDirs && (w = !1), w && d && t.dateModified && g != null) {
1699
- const [$, T] = t.dateModified;
1700
- ($ != null && g < $ || T != null && g > T) && (w = !1);
1691
+ if (d && !r.matchFiles && (w = !1), f && !r.matchDirs && (w = !1), w && d && r.dateModified && g != null) {
1692
+ const [I, T] = r.dateModified;
1693
+ (I != null && g < I || T != null && g > T) && (w = !1);
1701
1694
  }
1702
- if (w && d && t.totalSize && y != null) {
1703
- const [$, T] = t.totalSize;
1704
- ($ != null && y < $ || T != null && y > T) && (w = !1);
1695
+ if (w && d && r.totalSize && y != null) {
1696
+ const [I, T] = r.totalSize;
1697
+ (I != null && y < I || T != null && y > T) && (w = !1);
1705
1698
  }
1706
1699
  if (f && !w) {
1707
1700
  if (!(l.countFiles && l.countFiles > 0)) return !1;
@@ -1717,26 +1710,26 @@ async function us(t) {
1717
1710
  };
1718
1711
  if (p == null)
1719
1712
  return n.dateModified = g, n.size = y, n.isMatched = w, !0;
1720
- r.set(p, M);
1713
+ t.set(p, M);
1721
1714
  const E = me(H(k.dirname(p)));
1722
1715
  let b = s.get(E);
1723
1716
  return b || (b = [], s.set(E, b)), b.push(p), !0;
1724
1717
  }
1725
1718
  }), {
1726
- idToNode: r,
1719
+ idToNode: t,
1727
1720
  idToChildIds: s
1728
1721
  };
1729
1722
  }
1730
1723
  const ds = [
1731
- { name: "[ ]", match: (t) => t === 32, min: 2, max: 81 },
1732
- { name: "[\\t]", match: (t) => t === 9, min: 2, max: 20 },
1733
- { name: "[\\n]", match: (t) => t === 10, min: 2, max: 14 },
1734
- { name: "[-]", match: (t) => t === 45, min: 2, max: 16 },
1735
- { name: "[=]", match: (t) => t === 61, min: 2, max: 16 },
1736
- { name: "[_]", match: (t) => t === 95, min: 2, max: 16 },
1737
- { name: "[*]", match: (t) => t === 42, min: 2, max: 16 },
1738
- { name: "[.]", match: (t) => t === 46, min: 2, max: 16 },
1739
- { name: "[0-9]", match: (t) => t >= 48 && t <= 57, min: 2, max: 3 }
1724
+ { name: "[ ]", match: (r) => r === 32, min: 2, max: 81 },
1725
+ { name: "[\\t]", match: (r) => r === 9, min: 2, max: 20 },
1726
+ { name: "[\\n]", match: (r) => r === 10, min: 2, max: 14 },
1727
+ { name: "[-]", match: (r) => r === 45, min: 2, max: 16 },
1728
+ { name: "[=]", match: (r) => r === 61, min: 2, max: 16 },
1729
+ { name: "[_]", match: (r) => r === 95, min: 2, max: 16 },
1730
+ { name: "[*]", match: (r) => r === 42, min: 2, max: 16 },
1731
+ { name: "[.]", match: (r) => r === 46, min: 2, max: 16 },
1732
+ { name: "[0-9]", match: (r) => r >= 48 && r <= 57, min: 2, max: 3 }
1740
1733
  // { name: '[a-z]', match: c => c >= 97 && c <= 122, min: 2, max: 2 },
1741
1734
  // { name: '[A-Z]', match: c => c >= 65 && c <= 90, min: 2, max: 2 },
1742
1735
  // Other ASCII symbols
@@ -1750,21 +1743,21 @@ const ds = [
1750
1743
  // max: 2,
1751
1744
  // },
1752
1745
  ];
1753
- function He(t, r = ds) {
1754
- const s = t.length;
1746
+ function He(r, t = ds) {
1747
+ const s = r.length;
1755
1748
  if (s === 0) return 0;
1756
- const o = r.length;
1749
+ const o = t.length;
1757
1750
  if (o === 0)
1758
1751
  return s;
1759
1752
  let e = 0, n = 0;
1760
1753
  for (; n < s; ) {
1761
- const i = t.charCodeAt(n);
1754
+ const i = r.charCodeAt(n);
1762
1755
  let a = !1;
1763
1756
  for (let c = 0; c < o; c++) {
1764
- const l = r[c];
1757
+ const l = t[c];
1765
1758
  if (l.match(i)) {
1766
1759
  let u = 1;
1767
- for (; ++n < s && l.match(t.charCodeAt(n)) && u < l.max; )
1760
+ for (; ++n < s && l.match(r.charCodeAt(n)) && u < l.max; )
1768
1761
  u++;
1769
1762
  if (u >= l.min) {
1770
1763
  e++, a = !0;
@@ -1776,27 +1769,27 @@ function He(t, r = ds) {
1776
1769
  }
1777
1770
  return e;
1778
1771
  }
1779
- function Nt(t) {
1780
- let r = 0;
1781
- return r += He(t.textOpen) + 1, t.textClose != null && (r += He(t.textClose) + 1), t.indent && (r += 1), r;
1772
+ function Nt(r) {
1773
+ let t = 0;
1774
+ return t += He(r.textOpen) + 1, r.textClose != null && (t += He(r.textClose) + 1), r.indent && (t += 1), t;
1782
1775
  }
1783
1776
  const Qe = ["B", "KB", "MB", "GB", "TB"], Ye = 1024;
1784
- function fs(t) {
1785
- if (t == null) return "-";
1786
- let r = t ?? 0, s = 0;
1787
- for (; r >= Ye && s < Qe.length - 1; )
1788
- r /= Ye, s++;
1789
- return `${s === 0 ? r.toString() : r.toFixed(2)}${Qe[s]}`;
1790
- }
1791
- function ps(t) {
1792
- const s = Date.now() - t;
1777
+ function fs(r) {
1778
+ if (r == null) return "-";
1779
+ let t = r ?? 0, s = 0;
1780
+ for (; t >= Ye && s < Qe.length - 1; )
1781
+ t /= Ye, s++;
1782
+ return `${s === 0 ? t.toString() : t.toFixed(2)}${Qe[s]}`;
1783
+ }
1784
+ function ps(r) {
1785
+ const s = Date.now() - r;
1793
1786
  if (s < 0) return "0s";
1794
1787
  const o = Math.floor(s / 1e3), e = Math.floor(o / 60), n = Math.floor(e / 60), i = Math.floor(n / 24), a = Math.floor(i / 7), c = Math.floor(i / 30), l = Math.floor(i / 365);
1795
1788
  return l > 0 ? `${l}Y` : c > 0 ? `${c}M` : a > 0 ? `${a}w` : i > 0 ? `${i}d` : n > 0 ? `${n}h` : e > 0 ? `${e}m` : `${o}s`;
1796
1789
  }
1797
- function hs(t) {
1790
+ function hs(r) {
1798
1791
  return function(s, o) {
1799
- const e = t.get(s), n = t.get(o);
1792
+ const e = r.get(s), n = r.get(o);
1800
1793
  if (e.type !== n.type)
1801
1794
  return e.type === "file" ? -1 : 1;
1802
1795
  if (e.type === "file")
@@ -1807,20 +1800,20 @@ function hs(t) {
1807
1800
  }
1808
1801
  };
1809
1802
  }
1810
- function ms(t) {
1811
- const r = t.fields ?? [];
1803
+ function ms(r) {
1804
+ const t = r.fields ?? [];
1812
1805
  return function(o, e) {
1813
1806
  let n = "", i, a = 0;
1814
1807
  const c = e ? e.length : 0;
1815
1808
  let l = 1, u, f = 0, d = 0, p = 0, h = 0, g = null, y, w, M;
1816
1809
  if (e)
1817
1810
  for (let b = 0; b < e.length; b++) {
1818
- const $ = e[b];
1819
- a += $.countMatched, l += $.countTotal, f += $.tokens, d += $.tokensTotal, p += $.size, h += $.countFiles, $.dateModified != null && (g == null || $.dateModified > g) && (g = $.dateModified);
1811
+ const I = e[b];
1812
+ a += I.countMatched, l += I.countTotal, f += I.tokens, d += I.tokensTotal, p += I.size, h += I.countFiles, I.dateModified != null && (g == null || I.dateModified > g) && (g = I.dateModified);
1820
1813
  }
1821
1814
  o ? (y = o.type, w = o.name, M = o.path, i = o.isMatched, i && (a += 1), o.type === "file" ? (p = o.size || 0, h = 1, g = o.dateModified || null) : o.dateModified != null && (g == null || o.dateModified > g) && (g = o.dateModified)) : (y = "dir", w = "<root>", M = ".", i = !0);
1822
- for (let b = 0, $ = r.length; b < $; b++) {
1823
- const T = r[b];
1815
+ for (let b = 0, I = t.length; b < I; b++) {
1816
+ const T = t[b];
1824
1817
  switch (b > 0 && (n += " "), T) {
1825
1818
  case "dateModified":
1826
1819
  n += g ? ps(g) : "-";
@@ -1862,8 +1855,8 @@ function ms(t) {
1862
1855
  };
1863
1856
  };
1864
1857
  }
1865
- async function gs(t) {
1866
- const r = await us(t), s = le(r), o = s.getChilds(s.root), e = Et({
1858
+ async function gs(r) {
1859
+ const t = await us(r), s = le(t), o = s.getChilds(s.root), e = Et({
1867
1860
  getId: (i) => {
1868
1861
  const a = s.getId(i);
1869
1862
  if (a == null)
@@ -1873,7 +1866,7 @@ async function gs(t) {
1873
1866
  return a;
1874
1867
  },
1875
1868
  getChilds: (i) => s.getChilds(i),
1876
- createSnapshotNode: ms(t),
1869
+ createSnapshotNode: ms(r),
1877
1870
  rootNodes: o ?? []
1878
1871
  }), n = hs(e.idToNode);
1879
1872
  return e.idToChildIds.forEach((i) => {
@@ -1889,10 +1882,10 @@ const ee = m.object({
1889
1882
  "Unique name for the filesystem snapshot. Recommended format: kebab-case-1, kebab-case-2, ..."
1890
1883
  )
1891
1884
  });
1892
- async function ce(t, r, s) {
1885
+ async function ce(r, t, s) {
1893
1886
  let o;
1894
1887
  try {
1895
- o = ee.parse(t);
1888
+ o = ee.parse(r);
1896
1889
  } catch (u) {
1897
1890
  return {
1898
1891
  error: F(u)
@@ -1919,7 +1912,7 @@ async function ce(t, r, s) {
1919
1912
  } else if (i) {
1920
1913
  const u = await Ct(
1921
1914
  i,
1922
- r,
1915
+ t,
1923
1916
  s
1924
1917
  );
1925
1918
  if (u.error != null)
@@ -1947,8 +1940,8 @@ async function ce(t, r, s) {
1947
1940
  };
1948
1941
  }
1949
1942
  }
1950
- function ws(t, r) {
1951
- t(
1943
+ function ws(r, t) {
1944
+ r(
1952
1945
  "fs-snapshot-create",
1953
1946
  {
1954
1947
  title: "Create Filesystem Snapshot",
@@ -1956,7 +1949,7 @@ function ws(t, r) {
1956
1949
  inputSchema: ee.shape
1957
1950
  },
1958
1951
  async (s, o) => {
1959
- const e = await ce(s, r, o);
1952
+ const e = await ce(s, t, o);
1960
1953
  if (e.error != null)
1961
1954
  return `Method: fs-snapshot-create(${JSON.stringify(s)})
1962
1955
  ❌ Error: ${e.error}`;
@@ -1971,14 +1964,14 @@ class ys {
1971
1964
  _first = null;
1972
1965
  _last = null;
1973
1966
  _size = 0;
1974
- enqueue(r) {
1975
- const s = { item: r, next: null };
1967
+ enqueue(t) {
1968
+ const s = { item: t, next: null };
1976
1969
  this._last ? this._last.next = s : this._first = s, this._last = s, this._size += 1;
1977
1970
  }
1978
1971
  dequeue() {
1979
1972
  if (!this._first) return null;
1980
- const r = this._first.item;
1981
- return this._first = this._first.next, this._first || (this._last = null), this._size -= 1, r;
1973
+ const t = this._first.item;
1974
+ return this._first = this._first.next, this._first || (this._last = null), this._size -= 1, t;
1982
1975
  }
1983
1976
  peek() {
1984
1977
  return this._first ? this._first.item : null;
@@ -1990,38 +1983,38 @@ class ys {
1990
1983
  return this._size;
1991
1984
  }
1992
1985
  }
1993
- function bs(t) {
1994
- const r = new ys(), {
1986
+ function bs(r) {
1987
+ const t = new ys(), {
1995
1988
  tree: s,
1996
1989
  limits: { maxCountTotal: o, maxTokensTotal: e, maxCountGroup: n, maxTokensGroup: i },
1997
1990
  indexRangeGroupStrategy: a
1998
- } = t, c = s.getChilds(s.root);
1999
- c != null && c.length > 0 && r.enqueue({
1991
+ } = r, c = s.getChilds(s.root);
1992
+ c != null && c.length > 0 && t.enqueue({
2000
1993
  reportNode: null,
2001
1994
  node: s.root
2002
1995
  });
2003
1996
  let l = null, u = 0, f = 0;
2004
- for (; !r.isEmpty(); ) {
2005
- const { reportNode: d, node: p } = r.dequeue(), h = s.getChilds(p);
1997
+ for (; !t.isEmpty(); ) {
1998
+ const { reportNode: d, node: p } = t.dequeue(), h = s.getChilds(p);
2006
1999
  if (h == null || p.countChilds === 0 || h.length !== p.countChilds)
2007
2000
  throw new Error(
2008
2001
  "Impossible behavior: nodeChilds is null or length mismatch"
2009
2002
  );
2010
- let g = r.size();
2003
+ let g = t.size();
2011
2004
  for (let w = 0; w < h.length; w++)
2012
2005
  h[w].countChilds > 0 && (g += 1);
2013
2006
  const y = g * a.tokens;
2014
2007
  if (o != null && u + p.countChilds + g > o || e != null && f + p.tokensChilds + y > e) {
2015
2008
  const w = [];
2016
2009
  let M = null, E = 0;
2017
- for (let $ = 0, T = h.length; $ < T; $++) {
2018
- const x = h[$], S = E * a.tokens;
2010
+ for (let I = 0, T = h.length; I < T; I++) {
2011
+ const x = h[I], S = E * a.tokens;
2019
2012
  M != null && // Если общий лимит превышен, то не создаем новую группу, а продолжаем текущую. В случае достижения лимитов, последняя группа может содержать больше элементов, чем указано в лимитах группы, и это допустимо. Главное - дать в отчете полную картину.
2020
- !(o != null && u + 1 > o || e != null && f + a.tokens > e) && (n != null && M.countGrouped + 1 + E > n || i != null && M.tokensGrouped + x.tokens + S > i) && (w.push(M), u += 1, f += a.tokens, M = null, E = 0), M = a.add(M, x, $), x.countChilds > 0 && (E += 1);
2013
+ !(o != null && u + 1 > o || e != null && f + a.tokens > e) && (n != null && M.countGrouped + 1 + E > n || i != null && M.tokensGrouped + x.tokens + S > i) && (w.push(M), u += 1, f += a.tokens, M = null, E = 0), M = a.add(M, x, I), x.countChilds > 0 && (E += 1);
2021
2014
  }
2022
2015
  M != null && (w.push(M), u += 1, f += a.tokens);
2023
- const b = w.map(($) => ({
2024
- text: a.getReportText($)
2016
+ const b = w.map((I) => ({
2017
+ text: a.getReportText(I)
2025
2018
  }));
2026
2019
  if (d != null) {
2027
2020
  if (d.childs != null)
@@ -2040,8 +2033,8 @@ function bs(t) {
2040
2033
  text: E.text
2041
2034
  };
2042
2035
  w.push(b);
2043
- const $ = s.getChilds(E);
2044
- $ != null && $.length > 0 && r.enqueue({
2036
+ const I = s.getChilds(E);
2037
+ I != null && I.length > 0 && t.enqueue({
2045
2038
  reportNode: b,
2046
2039
  node: E
2047
2040
  });
@@ -2059,28 +2052,26 @@ function bs(t) {
2059
2052
  }
2060
2053
  return l ?? [];
2061
2054
  }
2062
- function kt(t) {
2055
+ function kt(r) {
2063
2056
  const {
2064
- tree: r,
2057
+ tree: t,
2065
2058
  request: { parentNodeId: s, childsIndexRange: o, limits: e },
2066
2059
  indexRangeGroupStrategy: n,
2067
2060
  ...i
2068
- } = t;
2061
+ } = r;
2069
2062
  let a;
2070
2063
  if (s != null) {
2071
- const d = r.getNode(s);
2064
+ const d = t.getNode(s);
2072
2065
  if (d == null)
2073
2066
  throw new Error(`Parent node "${s}" not found`);
2074
2067
  a = d;
2075
2068
  } else
2076
- a = r.root;
2077
- let c, l = r.getChilds(a) ?? [];
2069
+ a = t.root;
2070
+ let c, l = t.getChilds(a) ?? [];
2078
2071
  if (o != null) {
2079
- const [d, p] = o;
2080
- if (d < 0 || p <= d || p >= l.length)
2081
- throw new Error(
2082
- `Invalid index range: ${d}-${p} for root nodes length ${l.length}`
2083
- );
2072
+ let [d, p] = o;
2073
+ if (d < 0 && (d = 0), p < 0 && (p = 0), p >= l.length && (p = l.length - 1), p < d)
2074
+ return [];
2084
2075
  const h = [];
2085
2076
  let g = null;
2086
2077
  for (let y = d; y <= p; y++) {
@@ -2099,9 +2090,9 @@ function kt(t) {
2099
2090
  countChilds: 1,
2100
2091
  tokensChilds: c.tokens
2101
2092
  }, f = {
2102
- ...r,
2093
+ ...t,
2103
2094
  root: u,
2104
- getChilds: (d) => d === u ? [c] : d === c ? l : r.getChilds(d)
2095
+ getChilds: (d) => d === u ? [c] : d === c ? l : t.getChilds(d)
2105
2096
  };
2106
2097
  return bs({
2107
2098
  tree: f,
@@ -2110,8 +2101,8 @@ function kt(t) {
2110
2101
  ...i
2111
2102
  });
2112
2103
  }
2113
- function Ot(t, r) {
2114
- if (t == null || t.length === 0)
2104
+ function Ot(r, t) {
2105
+ if (r == null || r.length === 0)
2115
2106
  return "No results found";
2116
2107
  let s = "";
2117
2108
  function o(e, n) {
@@ -2125,22 +2116,22 @@ function Ot(t, r) {
2125
2116
  `);
2126
2117
  }
2127
2118
  }
2128
- return o(t, ""), s;
2119
+ return o(r, ""), s;
2129
2120
  }
2130
2121
  class Ss {
2131
2122
  tokens = 16;
2132
2123
  // +1 indent, +1 for line break
2133
- getReportText = (r) => ({
2124
+ getReportText = (t) => ({
2134
2125
  indent: !0,
2135
- textOpen: `[${r.indexRange[0]}-${r.indexRange[1]}] see more ${r.countMatched} matched ${r.tokensGrouped} tokens`,
2126
+ textOpen: `[${t.indexRange[0]}-${t.indexRange[1]}] see more ${t.countMatched} matched ${t.tokensGrouped} tokens`,
2136
2127
  textClose: null
2137
2128
  });
2138
- add = (r, s, o) => r == null ? {
2129
+ add = (t, s, o) => t == null ? {
2139
2130
  indexRange: [o, o],
2140
2131
  countGrouped: 1,
2141
2132
  countMatched: s.countMatched,
2142
2133
  tokensGrouped: s.tokens
2143
- } : (r.indexRange[1] = o, r.countGrouped += 1, r.countMatched += s.countMatched, r.tokensGrouped += s.tokens, r);
2134
+ } : (t.indexRange[1] = o, t.countGrouped += 1, t.countMatched += s.countMatched, t.tokensGrouped += s.tokens, t);
2144
2135
  }
2145
2136
  const Rt = m.object({
2146
2137
  snapshotName: m.string().optional().describe("Name of previously created filesystem snapshot, to use"),
@@ -2164,10 +2155,10 @@ const Rt = m.object({
2164
2155
  // maxCountGroup: z.number().default(10).describe('Maximum items per group'),
2165
2156
  // maxTokensGroup: z.number().default(1000).describe('Maximum tokens per group'),
2166
2157
  });
2167
- async function xs(t, r, s) {
2158
+ async function xs(r, t, s) {
2168
2159
  let o;
2169
2160
  try {
2170
- o = Rt.parse(t);
2161
+ o = Rt.parse(r);
2171
2162
  } catch (g) {
2172
2163
  return {
2173
2164
  error: F(g)
@@ -2199,7 +2190,7 @@ async function xs(t, r, s) {
2199
2190
  } else if (n) {
2200
2191
  const g = await ce(
2201
2192
  n,
2202
- r,
2193
+ t,
2203
2194
  s
2204
2195
  );
2205
2196
  if (g.error != null)
@@ -2240,8 +2231,8 @@ async function xs(t, r, s) {
2240
2231
  };
2241
2232
  }
2242
2233
  }
2243
- function $s(t, r) {
2244
- t(
2234
+ function Is(r, t) {
2235
+ r(
2245
2236
  "fs-snapshot-browse",
2246
2237
  {
2247
2238
  title: "Browse Filesystem Snapshot",
@@ -2249,7 +2240,7 @@ function $s(t, r) {
2249
2240
  inputSchema: Rt.shape
2250
2241
  },
2251
2242
  async (s, o) => {
2252
- const e = await xs(s, r, o);
2243
+ const e = await xs(s, t, o);
2253
2244
  if (e.error != null)
2254
2245
  return `Method: fs-snapshot-browse(${JSON.stringify(s)})
2255
2246
  ❌ Error: ${e.error}`;
@@ -2271,26 +2262,26 @@ ${e.report}`, n;
2271
2262
  }
2272
2263
  );
2273
2264
  }
2274
- function Dt(t) {
2275
- const r = [], s = t.tree, o = t.query.rootDir ?? ".";
2265
+ function Dt(r) {
2266
+ const t = [], s = r.tree, o = r.query.rootDir ?? ".";
2276
2267
  function e(n) {
2277
- n.type === "file" && n.isMatched && r.push(o + "/" + n.path);
2268
+ n.type === "file" && n.isMatched && t.push(o + "/" + n.path);
2278
2269
  const i = s.getChilds(n);
2279
2270
  if (i != null)
2280
2271
  for (let a = 0; a < i.length; a++)
2281
2272
  e(i[a]);
2282
2273
  }
2283
- return e(s.root), r;
2274
+ return e(s.root), t;
2284
2275
  }
2285
2276
  const Ve = /* @__PURE__ */ new Map();
2286
- function Is(t) {
2287
- const r = H(t);
2288
- let s = Ve.get(r);
2289
- return s == null && (s = new nr(), Ve.set(r, s)), s;
2290
- }
2291
- async function Ms(t) {
2292
- const { filePath: r, func: s } = t;
2293
- return Is(r).lock(
2277
+ function $s(r) {
2278
+ const t = H(r);
2279
+ let s = Ve.get(t);
2280
+ return s == null && (s = new nr(), Ve.set(t, s)), s;
2281
+ }
2282
+ async function Ms(r) {
2283
+ const { filePath: t, func: s } = r;
2284
+ return $s(t).lock(
2294
2285
  () => V({
2295
2286
  pool: Se,
2296
2287
  count: 1,
@@ -2299,21 +2290,21 @@ async function Ms(t) {
2299
2290
  );
2300
2291
  }
2301
2292
  const Ze = 10, re = 48, Xe = 57, de = 36, Ts = 38, Cs = 39, vs = 60, Es = 62, Ns = 96, se = 0, et = 1, tt = 2, rt = 3, st = 4, ks = 5;
2302
- function Os(t) {
2303
- const { content: r, pattern: s, replacement: o } = t, e = r.length, n = [0];
2293
+ function Os(r) {
2294
+ const { content: t, pattern: s, replacement: o } = r, e = t.length, n = [0];
2304
2295
  for (let b = 0; b < e; b++)
2305
- r.charCodeAt(b) === Ze && b + 1 < e && n.push(b + 1);
2296
+ t.charCodeAt(b) === Ze && b + 1 < e && n.push(b + 1);
2306
2297
  const i = n.length, a = [], c = [];
2307
2298
  let l = null, u = null, f = null, d = 0;
2308
2299
  if (o != null) {
2309
2300
  const b = o.length;
2310
- let $ = !1;
2301
+ let I = !1;
2311
2302
  for (let T = 0; T < b; T++)
2312
2303
  if (o.charCodeAt(T) === de) {
2313
- $ = !0;
2304
+ I = !0;
2314
2305
  break;
2315
2306
  }
2316
- if ($) {
2307
+ if (I) {
2317
2308
  u = [], f = [];
2318
2309
  let T = 0, x = 0;
2319
2310
  for (; x < b; ) {
@@ -2332,18 +2323,18 @@ function Os(t) {
2332
2323
  else if (S === Cs)
2333
2324
  v = rt;
2334
2325
  else if (S >= re && S <= Xe) {
2335
- let I = x + 2;
2336
- for (; I < b; ) {
2337
- const C = o.charCodeAt(I);
2326
+ let $ = x + 2;
2327
+ for (; $ < b; ) {
2328
+ const C = o.charCodeAt($);
2338
2329
  if (C < re || C > Xe) break;
2339
- I++;
2330
+ $++;
2340
2331
  }
2341
- v = st, P = o.substring(x + 1, I), O = I - x;
2332
+ v = st, P = o.substring(x + 1, $), O = $ - x;
2342
2333
  } else if (S === vs) {
2343
- let I = x + 2;
2344
- for (; I < b && o.charCodeAt(I) !== Es; )
2345
- I++;
2346
- I < b && I > x + 2 && (v = ks, P = o.substring(x + 2, I), O = I + 1 - x);
2334
+ let $ = x + 2;
2335
+ for (; $ < b && o.charCodeAt($) !== Es; )
2336
+ $++;
2337
+ $ < b && $ > x + 2 && (v = ks, P = o.substring(x + 2, $), O = $ + 1 - x);
2347
2338
  }
2348
2339
  v >= 0 ? (x > T && (u.push(se), f.push(o.substring(T, x))), u.push(v), f.push(P), x += O, T = x) : x++;
2349
2340
  }
@@ -2354,24 +2345,24 @@ function Os(t) {
2354
2345
  let p = "", h = 0, g = 0;
2355
2346
  s.lastIndex = 0;
2356
2347
  let y;
2357
- for (; (y = s.exec(r)) !== null; ) {
2358
- const b = y.index, $ = y[0], T = $.length, x = b + T;
2348
+ for (; (y = s.exec(t)) !== null; ) {
2349
+ const b = y.index, I = y[0], T = I.length, x = b + T;
2359
2350
  let S, v, P, O;
2360
2351
  if (i === 1)
2361
2352
  S = 0, v = 1, P = 0, O = e;
2362
2353
  else {
2363
- let I = 0, C = i - 1;
2364
- for (; I < C; ) {
2365
- const N = I + C + 1 >> 1;
2366
- n[N] <= b ? I = N : C = N - 1;
2354
+ let $ = 0, C = i - 1;
2355
+ for (; $ < C; ) {
2356
+ const N = $ + C + 1 >> 1;
2357
+ n[N] <= b ? $ = N : C = N - 1;
2367
2358
  }
2368
- if (S = I, T > 0) {
2359
+ if (S = $, T > 0) {
2369
2360
  const N = x - 1;
2370
- for (C = i - 1; I < C; ) {
2371
- const R = I + C + 1 >> 1;
2372
- n[R] <= N ? I = R : C = R - 1;
2361
+ for (C = i - 1; $ < C; ) {
2362
+ const R = $ + C + 1 >> 1;
2363
+ n[R] <= N ? $ = R : C = R - 1;
2373
2364
  }
2374
- v = I + 1;
2365
+ v = $ + 1;
2375
2366
  } else
2376
2367
  v = S + 1;
2377
2368
  P = n[S], O = v < i ? n[v] : e;
@@ -2381,68 +2372,68 @@ function Os(t) {
2381
2372
  lines: [S, v],
2382
2373
  linesOffset: [P, O]
2383
2374
  }), o != null) {
2384
- p += r.substring(h, b);
2385
- let I;
2375
+ p += t.substring(h, b);
2376
+ let $;
2386
2377
  if (l != null)
2387
- I = l;
2378
+ $ = l;
2388
2379
  else {
2389
- I = "";
2380
+ $ = "";
2390
2381
  const N = y.groups, R = y.length - 1;
2391
2382
  for (let K = 0; K < d; K++) {
2392
2383
  const q = u[K], L = f[K];
2393
2384
  switch (q) {
2394
2385
  case se:
2395
- I += L;
2386
+ $ += L;
2396
2387
  break;
2397
2388
  case et:
2398
- I += $;
2389
+ $ += I;
2399
2390
  break;
2400
2391
  case tt:
2401
- I += r.substring(0, b);
2392
+ $ += t.substring(0, b);
2402
2393
  break;
2403
2394
  case rt:
2404
- I += r.substring(x);
2395
+ $ += t.substring(x);
2405
2396
  break;
2406
2397
  case st: {
2407
2398
  const B = L, z = B.length, A = B.charCodeAt(0) - re;
2408
2399
  if (z >= 2) {
2409
2400
  const _ = B.charCodeAt(1) - re, D = A * 10 + _;
2410
2401
  if (D >= 1 && D <= R) {
2411
- I += y[D] ?? "", z > 2 && (I += B.substring(2));
2402
+ $ += y[D] ?? "", z > 2 && ($ += B.substring(2));
2412
2403
  break;
2413
2404
  }
2414
2405
  }
2415
- A >= 1 && A <= R ? (I += y[A] ?? "", z > 1 && (I += B.substring(1))) : I += "$" + B;
2406
+ A >= 1 && A <= R ? ($ += y[A] ?? "", z > 1 && ($ += B.substring(1))) : $ += "$" + B;
2416
2407
  break;
2417
2408
  }
2418
2409
  default:
2419
- N != null ? I += N[L] ?? "" : I += "$<" + L + ">";
2410
+ N != null ? $ += N[L] ?? "" : $ += "$<" + L + ">";
2420
2411
  }
2421
2412
  }
2422
2413
  }
2423
- p += I;
2414
+ p += $;
2424
2415
  const C = b + g;
2425
2416
  c.push({
2426
- offset: [C, C + I.length],
2417
+ offset: [C, C + $.length],
2427
2418
  lines: [0, 0],
2428
2419
  linesOffset: [0, 0]
2429
- }), g += I.length - T, h = x;
2420
+ }), g += $.length - T, h = x;
2430
2421
  }
2431
2422
  if (T === 0 && s.lastIndex++, !s.global)
2432
2423
  break;
2433
2424
  }
2434
2425
  if (s.lastIndex = 0, o == null)
2435
- return { search: { content: r, matches: a }, replace: null };
2436
- p += r.substring(h);
2426
+ return { search: { content: t, matches: a }, replace: null };
2427
+ p += t.substring(h);
2437
2428
  const w = p.length, M = [0];
2438
2429
  for (let b = 0; b < w; b++)
2439
2430
  p.charCodeAt(b) === Ze && b + 1 < w && M.push(b + 1);
2440
2431
  const E = M.length;
2441
- for (let b = 0, $ = c.length; b < $; b++) {
2432
+ for (let b = 0, I = c.length; b < I; b++) {
2442
2433
  const T = c[b], x = T.offset[0], S = T.offset[1];
2443
- let v, P, O, I;
2434
+ let v, P, O, $;
2444
2435
  if (E === 1)
2445
- v = 0, P = 1, O = 0, I = w;
2436
+ v = 0, P = 1, O = 0, $ = w;
2446
2437
  else {
2447
2438
  let C = 0, N = E - 1;
2448
2439
  for (; C < N; ) {
@@ -2458,28 +2449,28 @@ function Os(t) {
2458
2449
  P = C + 1;
2459
2450
  } else
2460
2451
  P = v + 1;
2461
- O = M[v], I = P < E ? M[P] : w;
2452
+ O = M[v], $ = P < E ? M[P] : w;
2462
2453
  }
2463
- T.lines[0] = v, T.lines[1] = P, T.linesOffset[0] = O, T.linesOffset[1] = I;
2454
+ T.lines[0] = v, T.lines[1] = P, T.linesOffset[0] = O, T.linesOffset[1] = $;
2464
2455
  }
2465
2456
  return {
2466
- search: { content: r, matches: a },
2457
+ search: { content: t, matches: a },
2467
2458
  replace: { content: p, matches: c }
2468
2459
  };
2469
2460
  }
2470
- function Ft(t) {
2471
- if (t.length === 0)
2461
+ function Ft(r) {
2462
+ if (r.length === 0)
2472
2463
  return [];
2473
- const r = [...t].sort((i, a) => {
2464
+ const t = [...r].sort((i, a) => {
2474
2465
  const c = i.lines[0], l = a.lines[0];
2475
2466
  if (c > l) return 1;
2476
2467
  if (c < l) return -1;
2477
2468
  const u = i.lines[1], f = a.lines[1];
2478
2469
  return u > f ? 1 : u < f ? -1 : 0;
2479
2470
  }), s = [];
2480
- let o = [...r[0].offset], e = [...r[0].lines], n = [...r[0].linesOffset];
2481
- for (let i = 1; i < r.length; i++) {
2482
- const a = r[i];
2471
+ let o = [...t[0].offset], e = [...t[0].lines], n = [...t[0].linesOffset];
2472
+ for (let i = 1; i < t.length; i++) {
2473
+ const a = t[i];
2483
2474
  a.lines[0] <= e[1] ? (a.offset[0] < o[0] && (o[0] = a.offset[0]), a.offset[1] > o[1] && (o[1] = a.offset[1]), a.lines[1] > e[1] && (e[1] = a.lines[1], n[1] = a.linesOffset[1])) : (s.push({
2484
2475
  offset: o,
2485
2476
  lines: e,
@@ -2492,49 +2483,49 @@ function Ft(t) {
2492
2483
  linesOffset: n
2493
2484
  }), s;
2494
2485
  }
2495
- function oe(t, r, s, o) {
2486
+ function oe(r, t, s, o) {
2496
2487
  let e = 0, n = 0;
2497
2488
  for (let u = 0; u < s; u++)
2498
- t.charCodeAt(u) === 10 && (n = u + 1, e++);
2489
+ r.charCodeAt(u) === 10 && (n = u + 1, e++);
2499
2490
  const i = e, a = n;
2500
2491
  let c = s;
2501
2492
  for (; c < o; c++)
2502
- t.charCodeAt(c) === 10 && e++;
2493
+ r.charCodeAt(c) === 10 && e++;
2503
2494
  const l = e + 1;
2504
- for (; c < r; c++)
2505
- if (t.charCodeAt(c) === 10)
2495
+ for (; c < t; c++)
2496
+ if (r.charCodeAt(c) === 10)
2506
2497
  return { startLine: i, endLine: l, startLineOfs: a, endLineOfs: c + 1 };
2507
- return { startLine: i, endLine: l, startLineOfs: a, endLineOfs: r };
2498
+ return { startLine: i, endLine: l, startLineOfs: a, endLineOfs: t };
2508
2499
  }
2509
- function Rs(t, r) {
2510
- if (t.replace == null && r.replace == null) {
2511
- const U = [...t.search.matches, ...r.search.matches];
2500
+ function Rs(r, t) {
2501
+ if (r.replace == null && t.replace == null) {
2502
+ const U = [...r.search.matches, ...t.search.matches];
2512
2503
  return {
2513
- search: { content: t.search.content, matches: Ft(U) },
2504
+ search: { content: r.search.content, matches: Ft(U) },
2514
2505
  replace: null
2515
2506
  };
2516
2507
  }
2517
- const s = t.replace ?? t.search, o = r.replace ?? r.search, e = t.search.content, n = o.content, i = e.length, a = n.length, c = t.search.matches, l = s.matches, u = r.search.matches, f = o.matches, d = l.length, p = u.length, h = [], g = [];
2518
- let y = 0, w = 0, M = 0, E = 0, b = 0, $ = 0, T = 0, x = 0, S = 0, v = 0, P = 0, O = 0, I = 0, C = 0, N = 0, R = 0, K = 0, q = 0, L = 0, B = 0, z = 0, A = 0, _ = 0, D = 0;
2508
+ const s = r.replace ?? r.search, o = t.replace ?? t.search, e = r.search.content, n = o.content, i = e.length, a = n.length, c = r.search.matches, l = s.matches, u = t.search.matches, f = o.matches, d = l.length, p = u.length, h = [], g = [];
2509
+ let y = 0, w = 0, M = 0, E = 0, b = 0, I = 0, T = 0, x = 0, S = 0, v = 0, P = 0, O = 0, $ = 0, C = 0, N = 0, R = 0, K = 0, q = 0, L = 0, B = 0, z = 0, A = 0, _ = 0, D = 0;
2519
2510
  for (; y < d || w < p; )
2520
- if (y < d && (b = l[y].offset[0], $ = l[y].offset[1]), w < p && (T = u[w].offset[0], x = u[w].offset[1]), y < d && w < p && b < x && T < $) {
2521
- K = b < T ? b : T, S = $ > x ? $ : x, P = y, O = w, y++, w++;
2511
+ if (y < d && (b = l[y].offset[0], I = l[y].offset[1]), w < p && (T = u[w].offset[0], x = u[w].offset[1]), y < d && w < p && b < x && T < I) {
2512
+ K = b < T ? b : T, S = I > x ? I : x, P = y, O = w, y++, w++;
2522
2513
  do {
2523
2514
  for (v = S; y < d && l[y].offset[0] < S; )
2524
- $ = l[y].offset[1], $ > S && (S = $), y++;
2515
+ I = l[y].offset[1], I > S && (S = I), y++;
2525
2516
  for (; w < p && u[w].offset[0] < S; )
2526
2517
  x = u[w].offset[1], x > S && (S = x), w++;
2527
2518
  } while (S !== v);
2528
- I = 1 / 0, C = -1 / 0, q = K, L = M;
2519
+ $ = 1 / 0, C = -1 / 0, q = K, L = M;
2529
2520
  for (let G = P; G < y; G++)
2530
- B = c[G].offset[0], z = c[G].offset[1], A = l[G].offset[0], _ = l[G].offset[1], q < A && (D = q + L, D < I && (I = D), D = A + L, D > C && (C = D)), B < I && (I = B), z > C && (C = z), L += z - B - _ + A, q = _;
2531
- q < S && (D = q + L, D < I && (I = D), D = S + L, D > C && (C = D)), M = L, N = 1 / 0, R = -1 / 0, q = K, L = E;
2521
+ B = c[G].offset[0], z = c[G].offset[1], A = l[G].offset[0], _ = l[G].offset[1], q < A && (D = q + L, D < $ && ($ = D), D = A + L, D > C && (C = D)), B < $ && ($ = B), z > C && (C = z), L += z - B - _ + A, q = _;
2522
+ q < S && (D = q + L, D < $ && ($ = D), D = S + L, D > C && (C = D)), M = L, N = 1 / 0, R = -1 / 0, q = K, L = E;
2532
2523
  for (let G = O; G < w; G++)
2533
2524
  B = u[G].offset[0], z = u[G].offset[1], A = f[G].offset[0], _ = f[G].offset[1], q < B && (D = q + L, D < N && (N = D), D = B + L, D > R && (R = D)), A < N && (N = A), _ > R && (R = _), L += _ - A - z + B, q = z;
2534
2525
  q < S && (D = q + L, D < N && (N = D), D = S + L, D > R && (R = D)), E = L;
2535
- const U = oe(e, i, I, C);
2526
+ const U = oe(e, i, $, C);
2536
2527
  h.push({
2537
- offset: [I, C],
2528
+ offset: [$, C],
2538
2529
  lines: [U.startLine, U.endLine],
2539
2530
  linesOffset: [U.startLineOfs, U.endLineOfs]
2540
2531
  });
@@ -2553,10 +2544,10 @@ function Rs(t, r) {
2553
2544
  linesOffset: [U.startLineOfs, U.endLineOfs]
2554
2545
  }), M += z - B - _ + A, y++;
2555
2546
  } else {
2556
- B = u[w].offset[0], z = u[w].offset[1], A = f[w].offset[0], _ = f[w].offset[1], I = B + M, C = z + M;
2557
- const U = oe(e, i, I, C);
2547
+ B = u[w].offset[0], z = u[w].offset[1], A = f[w].offset[0], _ = f[w].offset[1], $ = B + M, C = z + M;
2548
+ const U = oe(e, i, $, C);
2558
2549
  h.push({
2559
- offset: [I, C],
2550
+ offset: [$, C],
2560
2551
  lines: [U.startLine, U.endLine],
2561
2552
  linesOffset: [U.startLineOfs, U.endLineOfs]
2562
2553
  }), g.push(f[w]), E += _ - A - z + B, w++;
@@ -2566,17 +2557,17 @@ function Rs(t, r) {
2566
2557
  replace: { content: n, matches: g }
2567
2558
  };
2568
2559
  }
2569
- async function Ds(t) {
2570
- const { filePath: r, operations: s, dryRun: o } = t;
2571
- return s.length === 0 ? { filePath: r, result: null } : Ms({
2572
- filePath: r,
2560
+ async function Ds(r) {
2561
+ const { filePath: t, operations: s, dryRun: o } = r;
2562
+ return s.length === 0 ? { filePath: t, result: null } : Ms({
2563
+ filePath: t,
2573
2564
  func: async () => {
2574
2565
  let e;
2575
2566
  try {
2576
- e = await j.promises.readFile(r, "utf-8");
2567
+ e = await j.promises.readFile(t, "utf-8");
2577
2568
  } catch (a) {
2578
2569
  return {
2579
- filePath: r,
2570
+ filePath: t,
2580
2571
  result: null,
2581
2572
  error: `Failed to read file: ${a instanceof Error ? a.message : a + ""}`
2582
2573
  };
@@ -2589,7 +2580,7 @@ async function Ds(t) {
2589
2580
  l = new RegExp(c.pattern, c.flags ?? "");
2590
2581
  } catch (d) {
2591
2582
  return {
2592
- filePath: r,
2583
+ filePath: t,
2593
2584
  result: null,
2594
2585
  error: `Invalid RegExp pattern "${c.pattern}": ${d instanceof Error ? d.message : d + ""}`
2595
2586
  };
@@ -2605,23 +2596,23 @@ async function Ds(t) {
2605
2596
  const a = n.replace.content;
2606
2597
  if (a !== e)
2607
2598
  try {
2608
- await j.promises.writeFile(r, a, "utf-8");
2599
+ await j.promises.writeFile(t, a, "utf-8");
2609
2600
  } catch (c) {
2610
2601
  return {
2611
- filePath: r,
2602
+ filePath: t,
2612
2603
  result: n,
2613
2604
  error: `Failed to write file: ${c instanceof Error ? c.message : c + ""}`
2614
2605
  };
2615
2606
  }
2616
2607
  }
2617
- return { filePath: r, result: n };
2608
+ return { filePath: t, result: n };
2618
2609
  }
2619
2610
  });
2620
2611
  }
2621
- async function $e(t) {
2622
- const { filePaths: r, operations: s, dryRun: o, dateModifiedMax: e } = t;
2612
+ async function Ie(r) {
2613
+ const { filePaths: t, operations: s, dryRun: o, dateModifiedMax: e } = r;
2623
2614
  return { results: await Promise.all(
2624
- r.map(async (i) => {
2615
+ t.map(async (i) => {
2625
2616
  if (e != null) {
2626
2617
  const a = await j.promises.stat(i).catch(() => null);
2627
2618
  if (a == null)
@@ -2642,26 +2633,26 @@ async function $e(t) {
2642
2633
  ) };
2643
2634
  }
2644
2635
  const Fs = 6;
2645
- function Ps(t) {
2646
- const { content: r, startLine: s } = t, o = t.padWidth ?? Fs;
2636
+ function Ps(r) {
2637
+ const { content: t, startLine: s } = r, o = r.padWidth ?? Fs;
2647
2638
  let e = "", n = 0, i = 0;
2648
- for (; n < r.length; ) {
2649
- const a = r.indexOf(`
2650
- `, n), c = a === -1 ? r.length : a + 1;
2651
- e += String(s + i + 1).padStart(o) + "→" + r.substring(n, c), n = c, i++;
2639
+ for (; n < t.length; ) {
2640
+ const a = t.indexOf(`
2641
+ `, n), c = a === -1 ? t.length : a + 1;
2642
+ e += String(s + i + 1).padStart(o) + "→" + t.substring(n, c), n = c, i++;
2652
2643
  }
2653
2644
  return e.length > 0 && !e.endsWith(`
2654
2645
  `) && (e += `
2655
2646
  `), e;
2656
2647
  }
2657
- function fe(t) {
2658
- const { content: r, matches: s, outputLimit: o } = t;
2648
+ function fe(r) {
2649
+ const { content: t, matches: s, outputLimit: o } = r;
2659
2650
  if (s.length === 0)
2660
2651
  return { output: "", truncated: !1 };
2661
2652
  const e = Ft(s);
2662
2653
  let n = "", i = !1;
2663
2654
  for (let a = 0; a < e.length; a++) {
2664
- const c = e[a], l = r.substring(
2655
+ const c = e[a], l = t.substring(
2665
2656
  c.linesOffset[0],
2666
2657
  c.linesOffset[1]
2667
2658
  ), u = Ps({
@@ -2678,12 +2669,12 @@ function fe(t) {
2678
2669
  return { output: n, truncated: i };
2679
2670
  }
2680
2671
  const ot = "BEFORE", nt = "AFTER";
2681
- function Bs(t) {
2682
- const { result: r, outputLimit: s } = t;
2683
- if (r.replace == null) {
2672
+ function Bs(r) {
2673
+ const { result: t, outputLimit: s } = r;
2674
+ if (t.replace == null) {
2684
2675
  const h = fe({
2685
- content: r.search.content,
2686
- matches: r.search.matches,
2676
+ content: t.search.content,
2677
+ matches: t.search.matches,
2687
2678
  outputLimit: s
2688
2679
  });
2689
2680
  return { output: h.output, truncated: h.truncated };
@@ -2696,21 +2687,21 @@ function Bs(t) {
2696
2687
  if (s != null && s < a)
2697
2688
  return { output: "", truncated: !0 };
2698
2689
  const c = s != null ? s - a : void 0, l = c != null ? Math.floor(c / 2) : void 0, u = fe({
2699
- content: r.search.content,
2700
- matches: r.search.matches,
2690
+ content: t.search.content,
2691
+ matches: t.search.matches,
2701
2692
  outputLimit: l
2702
2693
  }), f = c != null ? c - u.output.length : void 0, d = fe({
2703
- content: r.replace.content,
2704
- matches: r.replace.matches,
2694
+ content: t.replace.content,
2695
+ matches: t.replace.matches,
2705
2696
  outputLimit: f
2706
2697
  });
2707
2698
  return { output: o + u.output + e + n + d.output + i, truncated: u.truncated || d.truncated };
2708
2699
  }
2709
- function Ie(t) {
2710
- const { result: r, rootDir: s, errorsOnly: o } = t;
2700
+ function $e(r) {
2701
+ const { result: t, rootDir: s, errorsOnly: o } = r;
2711
2702
  let e = "";
2712
- for (let n = 0; n < r.results.length; n++) {
2713
- const i = r.results[n], a = k.relative(s, i.filePath), c = e.length > 0 ? 1 : 0;
2703
+ for (let n = 0; n < t.results.length; n++) {
2704
+ const i = t.results[n], a = k.relative(s, i.filePath), c = e.length > 0 ? 1 : 0;
2714
2705
  if (i.error != null) {
2715
2706
  const u = a + `
2716
2707
  ❌ ` + i.error + `
@@ -2745,10 +2736,10 @@ const Ls = m.object({
2745
2736
  `Maximum output characters. Output exceeding this limit will be truncated. Maximum: ${J}. Default: ${Q}`
2746
2737
  )
2747
2738
  });
2748
- async function As(t, r, s) {
2739
+ async function As(r, t, s) {
2749
2740
  let o;
2750
2741
  try {
2751
- o = Pt.parse(t);
2742
+ o = Pt.parse(r);
2752
2743
  } catch (w) {
2753
2744
  return {
2754
2745
  error: F(w)
@@ -2773,7 +2764,7 @@ async function As(t, r, s) {
2773
2764
  } else if (n) {
2774
2765
  const w = await ce(
2775
2766
  n,
2776
- r,
2767
+ t,
2777
2768
  s
2778
2769
  );
2779
2770
  if (w.error != null)
@@ -2785,10 +2776,10 @@ async function As(t, r, s) {
2785
2776
  return {
2786
2777
  error: "Either snapshotName or snapshot must be provided"
2787
2778
  };
2788
- const d = Dt(l), p = l.query.rootDir ?? ".", h = await $e({
2779
+ const d = Dt(l), p = l.query.rootDir ?? ".", h = await Ie({
2789
2780
  filePaths: d,
2790
2781
  operations: i
2791
- }), g = Ie({
2782
+ }), g = $e({
2792
2783
  result: h,
2793
2784
  rootDir: p
2794
2785
  });
@@ -2798,8 +2789,8 @@ async function As(t, r, s) {
2798
2789
  limit: a
2799
2790
  }).content, rootDir: p, fsSnapshot: l, queryCreated: u, snapshotCreated: f };
2800
2791
  }
2801
- function zs(t, r) {
2802
- t(
2792
+ function zs(r, t) {
2793
+ r(
2803
2794
  "fs-snapshot-search",
2804
2795
  {
2805
2796
  title: "Search File Contents in Snapshot",
@@ -2809,7 +2800,7 @@ function zs(t, r) {
2809
2800
  async (s, o) => {
2810
2801
  const e = await As(
2811
2802
  s,
2812
- r,
2803
+ t,
2813
2804
  o
2814
2805
  );
2815
2806
  if (e.error != null)
@@ -2844,10 +2835,10 @@ const Us = m.object({
2844
2835
  `Maximum output characters. Output exceeding this limit will be truncated. Maximum: ${J}. Default: ${Q}`
2845
2836
  )
2846
2837
  });
2847
- async function js(t, r, s) {
2838
+ async function js(r, t, s) {
2848
2839
  let o;
2849
2840
  try {
2850
- o = Bt.parse(t);
2841
+ o = Bt.parse(r);
2851
2842
  } catch (b) {
2852
2843
  return {
2853
2844
  error: F(b)
@@ -2872,7 +2863,7 @@ async function js(t, r, s) {
2872
2863
  } else if (n) {
2873
2864
  const b = await ce(
2874
2865
  n,
2875
- r,
2866
+ t,
2876
2867
  s
2877
2868
  );
2878
2869
  if (b.error != null)
@@ -2887,7 +2878,7 @@ async function js(t, r, s) {
2887
2878
  const d = Dt(l), p = l.query.rootDir ?? ".", h = {
2888
2879
  filePaths: d,
2889
2880
  operations: i
2890
- }, g = Date.now(), y = await $e({
2881
+ }, g = Date.now(), y = await Ie({
2891
2882
  ...h,
2892
2883
  dryRun: !0
2893
2884
  }), w = as();
@@ -2897,7 +2888,7 @@ async function js(t, r, s) {
2897
2888
  rootDir: p,
2898
2889
  dateCreated: g
2899
2890
  };
2900
- const M = Ie({
2891
+ const M = $e({
2901
2892
  result: y,
2902
2893
  rootDir: p
2903
2894
  }) + `
@@ -2909,8 +2900,8 @@ Review the output carefully before executing. Call fs-snapshot-replace-execute w
2909
2900
  limit: a
2910
2901
  }).content, rootDir: p, fsSnapshot: l, queryCreated: u, snapshotCreated: f };
2911
2902
  }
2912
- function qs(t, r) {
2913
- t(
2903
+ function qs(r, t) {
2904
+ r(
2914
2905
  "fs-snapshot-replace-prepare",
2915
2906
  {
2916
2907
  title: "Prepare File Content Replacement",
@@ -2920,7 +2911,7 @@ function qs(t, r) {
2920
2911
  async (s, o) => {
2921
2912
  const e = await js(
2922
2913
  s,
2923
- r,
2914
+ t,
2924
2915
  o
2925
2916
  );
2926
2917
  if (e.error != null)
@@ -2942,10 +2933,10 @@ Reminder: use one snapshot covering all target files; include all patterns in th
2942
2933
  const Lt = m.object({
2943
2934
  replaceId: m.string().describe("Replace ID from the END of fs-snapshot-replace-prepare output. NEVER fabricate or guess this value.")
2944
2935
  });
2945
- async function _s(t, r, s) {
2936
+ async function _s(r, t, s) {
2946
2937
  let o;
2947
2938
  try {
2948
- o = Lt.parse(t);
2939
+ o = Lt.parse(r);
2949
2940
  } catch (l) {
2950
2941
  return {
2951
2942
  error: F(l)
@@ -2965,18 +2956,18 @@ async function _s(t, r, s) {
2965
2956
  return {
2966
2957
  error: `Invalid replaceId "${e}". The replaceId is located at the END of fs-snapshot-replace-prepare output. Read the ENTIRE output to find it. NEVER fabricate or guess this value.`
2967
2958
  };
2968
- const a = await $e({
2959
+ const a = await Ie({
2969
2960
  ...i.options,
2970
2961
  dateModifiedMax: i.dateCreated
2971
2962
  });
2972
- return n.preparedReplace = null, { output: Ie({
2963
+ return n.preparedReplace = null, { output: $e({
2973
2964
  result: a,
2974
2965
  rootDir: i.rootDir,
2975
2966
  errorsOnly: !0
2976
2967
  }) || null };
2977
2968
  }
2978
- function Gs(t, r) {
2979
- t(
2969
+ function Gs(r, t) {
2970
+ r(
2980
2971
  "fs-snapshot-replace-execute",
2981
2972
  {
2982
2973
  title: "Execute Prepared Replacement",
@@ -2986,7 +2977,7 @@ function Gs(t, r) {
2986
2977
  async (s, o) => {
2987
2978
  const e = await _s(
2988
2979
  s,
2989
- r,
2980
+ t,
2990
2981
  o
2991
2982
  );
2992
2983
  if (e.error != null)
@@ -2999,19 +2990,19 @@ ${e.output}`), n;
2999
2990
  }
3000
2991
  );
3001
2992
  }
3002
- function Js(t, r) {
3003
- r.list && ns(t, r), r.snapshotQueryCreate && cs(t, r), r.snapshotCreate && ws(t, r), r.snapshotBrowse && $s(t, r), r.snapshotSearch && zs(t, r), r.snapshotReplace && (qs(t, r), Gs(t, r)), console.log(
2993
+ function Js(r, t) {
2994
+ t.list && ns(r, t), t.snapshotQueryCreate && cs(r, t), t.snapshotCreate && ws(r, t), t.snapshotBrowse && Is(r, t), t.snapshotSearch && zs(r, t), t.snapshotReplace && (qs(r, t), Gs(r, t)), console.log(
3004
2995
  `File manager:
3005
- - Working directory: ${k.resolve(r.workingDir || "")}
2996
+ - Working directory: ${k.resolve(t.workingDir || "")}
3006
2997
  `
3007
2998
  );
3008
2999
  }
3009
3000
  const pe = /* @__PURE__ */ new Map();
3010
- function W(t) {
3011
- return pe.has(t) || pe.set(t, {
3001
+ function W(r) {
3002
+ return pe.has(r) || pe.set(r, {
3012
3003
  browsers: /* @__PURE__ */ new Map(),
3013
3004
  domSnapshotQueries: /* @__PURE__ */ new Map()
3014
- }), pe.get(t);
3005
+ }), pe.get(r);
3015
3006
  }
3016
3007
  const Me = m.object({
3017
3008
  name: m.string().describe(
@@ -3021,10 +3012,10 @@ const Me = m.object({
3021
3012
  muteAudio: m.boolean().optional().describe("Mute audio in the browser"),
3022
3013
  devTools: m.boolean().optional().describe("Open browser with dev tools")
3023
3014
  });
3024
- async function At(t, r, s) {
3015
+ async function At(r, t, s) {
3025
3016
  let o;
3026
3017
  try {
3027
- o = Me.parse(t);
3018
+ o = Me.parse(r);
3028
3019
  } catch (l) {
3029
3020
  return {
3030
3021
  error: F(l)
@@ -3058,8 +3049,8 @@ async function At(t, r, s) {
3058
3049
  };
3059
3050
  }
3060
3051
  }
3061
- function Ws(t, r) {
3062
- t(
3052
+ function Ws(r, t) {
3053
+ r(
3063
3054
  "playwright-browser-create",
3064
3055
  {
3065
3056
  title: "Create Browser",
@@ -3067,17 +3058,17 @@ function Ws(t, r) {
3067
3058
  inputSchema: Me.shape
3068
3059
  },
3069
3060
  async (s, o) => {
3070
- const e = await At(s, r, o);
3061
+ const e = await At(s, t, o);
3071
3062
  return `Method: playwright-browser-create(${JSON.stringify(s)})
3072
3063
  ${e.error != null ? `❌ Error: ${e.error}` : `✅ Browser "${e.browserInfo.name}" (${e.browserInfo.browserType}) created successfully`}`;
3073
3064
  }
3074
3065
  );
3075
3066
  }
3076
3067
  const zt = m.object({});
3077
- async function Ks(t, r, s) {
3068
+ async function Ks(r, t, s) {
3078
3069
  let o;
3079
3070
  try {
3080
- o = zt.parse(t);
3071
+ o = zt.parse(r);
3081
3072
  } catch (i) {
3082
3073
  return {
3083
3074
  error: F(i)
@@ -3092,8 +3083,8 @@ async function Ks(t, r, s) {
3092
3083
  browserInfos: Array.from(e.browsers.values())
3093
3084
  };
3094
3085
  }
3095
- function Hs(t, r) {
3096
- t(
3086
+ function Hs(r, t) {
3087
+ r(
3097
3088
  "playwright-browser-list",
3098
3089
  {
3099
3090
  title: "List Browsers",
@@ -3101,7 +3092,7 @@ function Hs(t, r) {
3101
3092
  inputSchema: zt.shape
3102
3093
  },
3103
3094
  async (s, o) => {
3104
- const e = await Ks(s, r, o);
3095
+ const e = await Ks(s, t, o);
3105
3096
  if (e.error != null)
3106
3097
  return `Method: playwright-browser-list(${JSON.stringify(s)})
3107
3098
  ❌ Error: ${e.error}`;
@@ -3118,10 +3109,10 @@ const Ut = m.object({
3118
3109
  "Names of browsers to close. If not specified, closes all browsers"
3119
3110
  )
3120
3111
  });
3121
- async function Qs(t, r, s) {
3112
+ async function Qs(r, t, s) {
3122
3113
  let o;
3123
3114
  try {
3124
- o = Ut.parse(t);
3115
+ o = Ut.parse(r);
3125
3116
  } catch (l) {
3126
3117
  return {
3127
3118
  error: F(l)
@@ -3152,8 +3143,8 @@ async function Qs(t, r, s) {
3152
3143
  ...a.length > 0 && { errors: a }
3153
3144
  };
3154
3145
  }
3155
- function Ys(t, r) {
3156
- t(
3146
+ function Ys(r, t) {
3147
+ r(
3157
3148
  "playwright-browser-close",
3158
3149
  {
3159
3150
  title: "Close Browsers",
@@ -3161,7 +3152,7 @@ function Ys(t, r) {
3161
3152
  inputSchema: Ut.shape
3162
3153
  },
3163
3154
  async (s, o) => {
3164
- const e = await Qs(s, r, o);
3155
+ const e = await Qs(s, t, o);
3165
3156
  if (e.error != null)
3166
3157
  return `Method: playwright-browser-close(${JSON.stringify(s)})
3167
3158
  ❌ Error: ${e.error}`;
@@ -3193,10 +3184,10 @@ const Te = m.object({
3193
3184
  height: m.number()
3194
3185
  }).optional().describe("Viewport size configuration")
3195
3186
  });
3196
- async function jt(t, r, s) {
3187
+ async function jt(r, t, s) {
3197
3188
  let o;
3198
3189
  try {
3199
- o = Te.parse(t);
3190
+ o = Te.parse(r);
3200
3191
  } catch (p) {
3201
3192
  return {
3202
3193
  error: F(p)
@@ -3219,7 +3210,7 @@ async function jt(t, r, s) {
3219
3210
  error: `Browser "${n}" not found`
3220
3211
  };
3221
3212
  } else if (i) {
3222
- const p = await At(i, r, s);
3213
+ const p = await At(i, t, s);
3223
3214
  if (p.error != null)
3224
3215
  return {
3225
3216
  error: p.error
@@ -3251,8 +3242,8 @@ async function jt(t, r, s) {
3251
3242
  };
3252
3243
  }
3253
3244
  }
3254
- function Vs(t, r) {
3255
- t(
3245
+ function Vs(r, t) {
3246
+ r(
3256
3247
  "playwright-context-create",
3257
3248
  {
3258
3249
  title: "Create Browser Context",
@@ -3260,7 +3251,7 @@ function Vs(t, r) {
3260
3251
  inputSchema: Te.shape
3261
3252
  },
3262
3253
  async (s, o) => {
3263
- const e = await jt(s, r, o);
3254
+ const e = await jt(s, t, o);
3264
3255
  if (e.error != null)
3265
3256
  return `Method: playwright-context-create(${JSON.stringify(s)})
3266
3257
  ❌ Error: ${e.error}`;
@@ -3276,10 +3267,10 @@ const qt = m.object({
3276
3267
  "Name of browser to list contexts from. If not specified, lists contexts from all browsers"
3277
3268
  )
3278
3269
  });
3279
- async function Zs(t, r, s) {
3270
+ async function Zs(r, t, s) {
3280
3271
  let o;
3281
3272
  try {
3282
- o = qt.parse(t);
3273
+ o = qt.parse(r);
3283
3274
  } catch (a) {
3284
3275
  return {
3285
3276
  error: F(a)
@@ -3313,8 +3304,8 @@ async function Zs(t, r, s) {
3313
3304
  contextsByBrowser: i
3314
3305
  };
3315
3306
  }
3316
- function Xs(t, r) {
3317
- t(
3307
+ function Xs(r, t) {
3308
+ r(
3318
3309
  "playwright-context-list",
3319
3310
  {
3320
3311
  title: "List Browser Contexts",
@@ -3322,7 +3313,7 @@ function Xs(t, r) {
3322
3313
  inputSchema: qt.shape
3323
3314
  },
3324
3315
  async (s, o) => {
3325
- const e = await Zs(s, r, o);
3316
+ const e = await Zs(s, t, o);
3326
3317
  if ("error" in e)
3327
3318
  return `Method: playwright-context-list(${JSON.stringify(s)})
3328
3319
  ❌ Error: ${e.error}`;
@@ -3343,10 +3334,10 @@ const _t = m.object({
3343
3334
  "Name of browser to close contexts from. If not specified, searches all browsers"
3344
3335
  )
3345
3336
  });
3346
- async function eo(t, r, s) {
3337
+ async function eo(r, t, s) {
3347
3338
  let o;
3348
3339
  try {
3349
- o = _t.parse(t);
3340
+ o = _t.parse(r);
3350
3341
  } catch (u) {
3351
3342
  return {
3352
3343
  error: F(u)
@@ -3397,8 +3388,8 @@ async function eo(t, r, s) {
3397
3388
  ...c.length > 0 && { errors: c }
3398
3389
  };
3399
3390
  }
3400
- function to(t, r) {
3401
- t(
3391
+ function to(r, t) {
3392
+ r(
3402
3393
  "playwright-context-close",
3403
3394
  {
3404
3395
  title: "Close Browser Contexts",
@@ -3406,7 +3397,7 @@ function to(t, r) {
3406
3397
  inputSchema: _t.shape
3407
3398
  },
3408
3399
  async (s, o) => {
3409
- const e = await eo(s, r, o);
3400
+ const e = await eo(s, t, o);
3410
3401
  if ("error" in e)
3411
3402
  return `Method: playwright-context-close(${JSON.stringify(s)})
3412
3403
  ❌ Error: ${e.error}`;
@@ -3424,7 +3415,7 @@ ${n.join(`
3424
3415
  );
3425
3416
  }
3426
3417
  function ro() {
3427
- class t {
3418
+ class r {
3428
3419
  prevId = 0;
3429
3420
  objectToId = /* @__PURE__ */ new WeakMap();
3430
3421
  idToObject = /* @__PURE__ */ new Map();
@@ -3446,16 +3437,16 @@ function ro() {
3446
3437
  return u ?? (this.idToObject.delete(c), null);
3447
3438
  }
3448
3439
  }
3449
- function r(a, c, l) {
3440
+ function t(a, c, l) {
3450
3441
  let u = null;
3451
3442
  for (let f = 0, d = c.length; f < d; f++) {
3452
- const p = c[f], h = a(p), g = h == null ? null : r(a, h, l), y = l(p, g);
3443
+ const p = c[f], h = a(p), g = h == null ? null : t(a, h, l), y = l(p, g);
3453
3444
  y != null && (u == null && (u = []), u.push(y));
3454
3445
  }
3455
3446
  return u;
3456
3447
  }
3457
3448
  function s(a) {
3458
- const { getId: c, getChilds: l, rootNodes: u, createSnapshotNode: f } = a, d = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), g = r(
3449
+ const { getId: c, getChilds: l, rootNodes: u, createSnapshotNode: f } = a, d = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), g = t(
3459
3450
  l,
3460
3451
  u,
3461
3452
  (w, M) => {
@@ -3499,7 +3490,7 @@ function ro() {
3499
3490
  };
3500
3491
  };
3501
3492
  }
3502
- const n = new t();
3493
+ const n = new r();
3503
3494
  function i(a) {
3504
3495
  const c = e(a);
3505
3496
  return s({
@@ -3520,10 +3511,10 @@ const so = `(function (){function __name(fn){return fn};${ro.toString()}; setupP
3520
3511
  "Unique name for the page. Recommended format: kebab-case-1, kebab-case-2, ..."
3521
3512
  )
3522
3513
  });
3523
- async function Gt(t, r, s) {
3514
+ async function Gt(r, t, s) {
3524
3515
  let o;
3525
3516
  try {
3526
- o = Ce.parse(t);
3517
+ o = Ce.parse(r);
3527
3518
  } catch (f) {
3528
3519
  return {
3529
3520
  error: F(f)
@@ -3551,7 +3542,7 @@ async function Gt(t, r, s) {
3551
3542
  error: `Context "${n}" not found`
3552
3543
  };
3553
3544
  } else if (i) {
3554
- const f = await jt(i, r, s);
3545
+ const f = await jt(i, t, s);
3555
3546
  if (f.error != null)
3556
3547
  return {
3557
3548
  error: f.error
@@ -3581,8 +3572,8 @@ async function Gt(t, r, s) {
3581
3572
  };
3582
3573
  }
3583
3574
  }
3584
- function oo(t, r) {
3585
- t(
3575
+ function oo(r, t) {
3576
+ r(
3586
3577
  "playwright-page-create",
3587
3578
  {
3588
3579
  title: "Create Page",
@@ -3590,7 +3581,7 @@ function oo(t, r) {
3590
3581
  inputSchema: Ce.shape
3591
3582
  },
3592
3583
  async (s, o) => {
3593
- const e = await Gt(s, r, o);
3584
+ const e = await Gt(s, t, o);
3594
3585
  if (e.error != null)
3595
3586
  return `Method: playwright-page-create(${JSON.stringify(s)})
3596
3587
  ❌ Error: ${e.error}`;
@@ -3610,10 +3601,10 @@ const Jt = m.object({
3610
3601
  "Name of browser to search in. If not specified, searches all browsers"
3611
3602
  )
3612
3603
  });
3613
- async function no(t, r, s) {
3604
+ async function no(r, t, s) {
3614
3605
  let o;
3615
3606
  try {
3616
- o = Jt.parse(t);
3607
+ o = Jt.parse(r);
3617
3608
  } catch (c) {
3618
3609
  return {
3619
3610
  error: F(c)
@@ -3674,8 +3665,8 @@ async function no(t, r, s) {
3674
3665
  pagesByContext: a
3675
3666
  };
3676
3667
  }
3677
- function io(t, r) {
3678
- t(
3668
+ function io(r, t) {
3669
+ r(
3679
3670
  "playwright-page-list",
3680
3671
  {
3681
3672
  title: "List Pages",
@@ -3683,7 +3674,7 @@ function io(t, r) {
3683
3674
  inputSchema: Jt.shape
3684
3675
  },
3685
3676
  async (s, o) => {
3686
- const e = await no(s, r, o);
3677
+ const e = await no(s, t, o);
3687
3678
  if ("error" in e)
3688
3679
  return `Method: playwright-page-list(${JSON.stringify(s)})
3689
3680
  ❌ Error: ${e.error}`;
@@ -3705,10 +3696,10 @@ const Wt = m.object({
3705
3696
  "Name of browser to search in. If not specified, searches all browsers"
3706
3697
  )
3707
3698
  });
3708
- async function ao(t, r, s) {
3699
+ async function ao(r, t, s) {
3709
3700
  let o;
3710
3701
  try {
3711
- o = Wt.parse(t);
3702
+ o = Wt.parse(r);
3712
3703
  } catch (f) {
3713
3704
  return {
3714
3705
  error: F(f)
@@ -3783,8 +3774,8 @@ async function ao(t, r, s) {
3783
3774
  ...l.length > 0 && { errors: l }
3784
3775
  };
3785
3776
  }
3786
- function lo(t, r) {
3787
- t(
3777
+ function lo(r, t) {
3778
+ r(
3788
3779
  "playwright-page-close",
3789
3780
  {
3790
3781
  title: "Close Pages",
@@ -3792,7 +3783,7 @@ function lo(t, r) {
3792
3783
  inputSchema: Wt.shape
3793
3784
  },
3794
3785
  async (s, o) => {
3795
- const e = await ao(s, r, o);
3786
+ const e = await ao(s, t, o);
3796
3787
  if ("error" in e)
3797
3788
  return `Method: playwright-page-close(${JSON.stringify(s)})
3798
3789
  ❌ Error: ${e.error}`;
@@ -3818,10 +3809,10 @@ const Kt = m.object({
3818
3809
  - 'commit': network response received and document started loading`
3819
3810
  )
3820
3811
  });
3821
- async function co(t, r, s) {
3812
+ async function co(r, t, s) {
3822
3813
  let o;
3823
3814
  try {
3824
- o = Kt.parse(t);
3815
+ o = Kt.parse(r);
3825
3816
  } catch (h) {
3826
3817
  return {
3827
3818
  error: F(h)
@@ -3852,7 +3843,7 @@ async function co(t, r, s) {
3852
3843
  error: `Page "${e}" not found`
3853
3844
  };
3854
3845
  } else if (n) {
3855
- const h = await Gt(n, r, s);
3846
+ const h = await Gt(n, t, s);
3856
3847
  if (h.error != null)
3857
3848
  return {
3858
3849
  error: h.error
@@ -3886,8 +3877,8 @@ async function co(t, r, s) {
3886
3877
  };
3887
3878
  }
3888
3879
  }
3889
- function uo(t, r) {
3890
- t(
3880
+ function uo(r, t) {
3881
+ r(
3891
3882
  "playwright-page-goto",
3892
3883
  {
3893
3884
  title: "Navigate Page",
@@ -3895,7 +3886,7 @@ function uo(t, r) {
3895
3886
  inputSchema: Kt.shape
3896
3887
  },
3897
3888
  async (s, o) => {
3898
- const e = await co(s, r, o);
3889
+ const e = await co(s, t, o);
3899
3890
  if (e.error != null)
3900
3891
  return `Method: playwright-page-goto(${JSON.stringify(s)})
3901
3892
  ❌ Error: ${e.error}`;
@@ -3914,10 +3905,10 @@ const ve = m.object({
3914
3905
  ),
3915
3906
  cssSelector: m.string().describe("CSS selector to capture page content")
3916
3907
  });
3917
- async function Ht(t, r, s) {
3908
+ async function Ht(r, t, s) {
3918
3909
  let o;
3919
3910
  try {
3920
- o = ve.parse(t);
3911
+ o = ve.parse(r);
3921
3912
  } catch (c) {
3922
3913
  return {
3923
3914
  error: F(c)
@@ -3936,8 +3927,8 @@ async function Ht(t, r, s) {
3936
3927
  snapshotQuery: a
3937
3928
  };
3938
3929
  }
3939
- function fo(t, r) {
3940
- t(
3930
+ function fo(r, t) {
3931
+ r(
3941
3932
  "playwright-dom-snapshot-query-create",
3942
3933
  {
3943
3934
  title: "Create DOM Snapshot Query",
@@ -3945,14 +3936,14 @@ function fo(t, r) {
3945
3936
  inputSchema: ve.shape
3946
3937
  },
3947
3938
  async (s, o) => {
3948
- const e = await Ht(s, r, o);
3939
+ const e = await Ht(s, t, o);
3949
3940
  return e.error != null ? `Method: playwright-dom-snapshot-query-create(${JSON.stringify(s)})
3950
3941
  ❌ Error: ${e.error}` : `Method: playwright-dom-snapshot-query-create(${JSON.stringify(s)})
3951
3942
  ✅ DOM snapshot query "${e.snapshotQuery.name}" created successfully`;
3952
3943
  }
3953
3944
  );
3954
3945
  }
3955
- function po(t) {
3946
+ function po(r) {
3956
3947
  return function(s, o) {
3957
3948
  let e, n = 0;
3958
3949
  const i = o ? o.length : 0;
@@ -3988,8 +3979,8 @@ function po(t) {
3988
3979
  };
3989
3980
  };
3990
3981
  }
3991
- function ho(t, r) {
3992
- const s = le(r), o = s.getChilds(s.root), e = Et({
3982
+ function ho(r, t) {
3983
+ const s = le(t), o = s.getChilds(s.root), e = Et({
3993
3984
  getId: (n) => {
3994
3985
  const i = s.getId(n);
3995
3986
  if (i == null)
@@ -4014,10 +4005,10 @@ const Ee = m.object({
4014
4005
  "Unique name for the DOM snapshot. Recommended format: kebab-case-1, kebab-case-2, ..."
4015
4006
  )
4016
4007
  });
4017
- async function Qt(t, r, s) {
4008
+ async function Qt(r, t, s) {
4018
4009
  let o;
4019
4010
  try {
4020
- o = Ee.parse(t);
4011
+ o = Ee.parse(r);
4021
4012
  } catch (d) {
4022
4013
  return {
4023
4014
  error: F(d)
@@ -4057,7 +4048,7 @@ async function Qt(t, r, s) {
4057
4048
  } else if (i) {
4058
4049
  const d = await Ht(
4059
4050
  i,
4060
- r,
4051
+ t,
4061
4052
  s
4062
4053
  );
4063
4054
  if (d.error != null)
@@ -4100,8 +4091,8 @@ async function Qt(t, r, s) {
4100
4091
  };
4101
4092
  }
4102
4093
  }
4103
- function mo(t, r) {
4104
- t(
4094
+ function mo(r, t) {
4095
+ r(
4105
4096
  "playwright-dom-snapshot-create",
4106
4097
  {
4107
4098
  title: "Create DOM Snapshot",
@@ -4109,7 +4100,7 @@ function mo(t, r) {
4109
4100
  inputSchema: Ee.shape
4110
4101
  },
4111
4102
  async (s, o) => {
4112
- const e = await Qt(s, r, o);
4103
+ const e = await Qt(s, t, o);
4113
4104
  if (e.error != null)
4114
4105
  return `Method: playwright-dom-snapshot-create(${JSON.stringify(s)})
4115
4106
  ❌ Error: ${e.error}`;
@@ -4122,17 +4113,17 @@ function mo(t, r) {
4122
4113
  }
4123
4114
  class go {
4124
4115
  tokens = 20;
4125
- getReportText = (r) => ({
4116
+ getReportText = (t) => ({
4126
4117
  indent: !0,
4127
- textOpen: `[${r.indexRange[0]}-${r.indexRange[1]}] see more ${r.countMatched} matched ${r.tokensGrouped} tokens`,
4118
+ textOpen: `[${t.indexRange[0]}-${t.indexRange[1]}] see more ${t.countMatched} matched ${t.tokensGrouped} tokens`,
4128
4119
  textClose: null
4129
4120
  });
4130
- add = (r, s, o) => r == null ? {
4121
+ add = (t, s, o) => t == null ? {
4131
4122
  indexRange: [o, o],
4132
4123
  countGrouped: 1,
4133
4124
  countMatched: s.countMatched,
4134
4125
  tokensGrouped: s.tokens
4135
- } : (r.indexRange[1] = o, r.countGrouped += 1, r.countMatched += s.countMatched, r.tokensGrouped += s.tokens, r);
4126
+ } : (t.indexRange[1] = o, t.countGrouped += 1, t.countMatched += s.countMatched, t.tokensGrouped += s.tokens, t);
4136
4127
  }
4137
4128
  const Yt = m.object({
4138
4129
  snapshotName: m.string().optional().describe("Name of previously created DOM snapshot, to use"),
@@ -4154,10 +4145,10 @@ const Yt = m.object({
4154
4145
  // maxCountGroup: z.number().default(10).describe('Maximum items per group'),
4155
4146
  // maxTokensGroup: z.number().default(1000).describe('Maximum tokens per group'),
4156
4147
  });
4157
- async function wo(t, r, s) {
4148
+ async function wo(r, t, s) {
4158
4149
  let o;
4159
4150
  try {
4160
- o = Yt.parse(t);
4151
+ o = Yt.parse(r);
4161
4152
  } catch (g) {
4162
4153
  return {
4163
4154
  error: F(g)
@@ -4200,7 +4191,7 @@ async function wo(t, r, s) {
4200
4191
  } else if (n) {
4201
4192
  const g = await Qt(
4202
4193
  n,
4203
- r,
4194
+ t,
4204
4195
  s
4205
4196
  );
4206
4197
  if (g.error != null)
@@ -4241,8 +4232,8 @@ async function wo(t, r, s) {
4241
4232
  };
4242
4233
  }
4243
4234
  }
4244
- function yo(t, r) {
4245
- t(
4235
+ function yo(r, t) {
4236
+ r(
4246
4237
  "playwright-dom-snapshot-browse",
4247
4238
  {
4248
4239
  title: "Browse DOM Snapshot",
@@ -4250,7 +4241,7 @@ function yo(t, r) {
4250
4241
  inputSchema: Yt.shape
4251
4242
  },
4252
4243
  async (s, o) => {
4253
- const e = await wo(s, r, o);
4244
+ const e = await wo(s, t, o);
4254
4245
  if (e.error != null)
4255
4246
  return `Method: playwright-dom-snapshot-browse(${JSON.stringify(s)})
4256
4247
  ❌ Error: ${e.error}`;
@@ -4271,14 +4262,14 @@ ${e.report}`, n;
4271
4262
  }
4272
4263
  );
4273
4264
  }
4274
- function bo(t, r) {
4275
- r.browserCreate && Ws(t, r), r.browserList && Hs(t, r), r.browserClose && Ys(t, r), r.contextCreate && Vs(t, r), r.contextList && Xs(t, r), r.contextClose && to(t, r), r.pageCreate && oo(t, r), r.pageList && io(t, r), r.pageClose && lo(t, r), r.pageGoto && uo(t, r), r.domSnapshotQueryCreate && fo(t, r), r.domSnapshotCreate && mo(t, r), r.domSnapshotBrowse && yo(t, r), console.log("Playwright manager");
4265
+ function bo(r, t) {
4266
+ t.browserCreate && Ws(r, t), t.browserList && Hs(r, t), t.browserClose && Ys(r, t), t.contextCreate && Vs(r, t), t.contextList && Xs(r, t), t.contextClose && to(r, t), t.pageCreate && oo(r, t), t.pageList && io(r, t), t.pageClose && lo(r, t), t.pageGoto && uo(r, t), t.domSnapshotQueryCreate && fo(r, t), t.domSnapshotCreate && mo(r, t), t.domSnapshotBrowse && yo(r, t), console.log("Playwright manager");
4276
4267
  }
4277
- function So(t) {
4278
- const { logFilePath: r } = t;
4268
+ function So(r) {
4269
+ const { logFilePath: t } = r;
4279
4270
  return async function(o, e, n, i) {
4280
4271
  await ie({
4281
- logFilePath: r,
4272
+ logFilePath: t,
4282
4273
  message: "ERROR",
4283
4274
  data: {
4284
4275
  request: {
@@ -4301,10 +4292,10 @@ const it = [
4301
4292
  "flemist-mcp.config.json5",
4302
4293
  "flemist-mcp.config.yaml"
4303
4294
  ];
4304
- async function xo(t) {
4305
- const r = k.resolve(t);
4295
+ async function xo(r) {
4296
+ const t = k.resolve(r);
4306
4297
  for (let s = 0, o = it.length; s < o; s++) {
4307
- const e = it[s], n = k.join(r, e);
4298
+ const e = it[s], n = k.join(t, e);
4308
4299
  try {
4309
4300
  await j.promises.stat(n);
4310
4301
  } catch {
@@ -4333,14 +4324,14 @@ ${c instanceof Error ? c.message : String(c)}`);
4333
4324
  ${c instanceof Error ? c.message : String(c)}`);
4334
4325
  }
4335
4326
  }
4336
- throw new Error(`MCP Error: No configuration file found in: ${r}
4327
+ throw new Error(`MCP Error: No configuration file found in: ${t}
4337
4328
 
4338
4329
  Expected one of:
4339
4330
  - flemist-mcp.config.json
4340
4331
  - flemist-mcp.config.json5
4341
4332
  - flemist-mcp.config.yaml`);
4342
4333
  }
4343
- const $o = {
4334
+ const Io = {
4344
4335
  logDir: "tmp/mcp-project-tools/logs",
4345
4336
  tools: {
4346
4337
  processManager: {
@@ -4381,27 +4372,27 @@ const $o = {
4381
4372
  }
4382
4373
  }
4383
4374
  };
4384
- async function Io(t) {
4385
- const r = k.resolve(t), s = await xo(r), o = k.join(r, ".flemist-mcpignore");
4375
+ async function $o(r) {
4376
+ const t = k.resolve(r), s = await xo(t), o = k.join(t, ".flemist-mcpignore");
4386
4377
  try {
4387
4378
  await j.promises.stat(o);
4388
4379
  } catch {
4389
4380
  throw new Error(`MCP Error: .flemist-mcpignore file not found in project directory.
4390
4381
 
4391
- Create .flemist-mcpignore file in: ${r}
4382
+ Create .flemist-mcpignore file in: ${t}
4392
4383
 
4393
4384
  This file contains glob patterns for files/directories to exclude from MCP operations.`);
4394
4385
  }
4395
- const e = dr($o, s, {
4386
+ const e = dr(Io, s, {
4396
4387
  arrayMerge(n, i) {
4397
4388
  return i;
4398
4389
  }
4399
4390
  });
4400
4391
  return e.tools?.processManager && (e.tools.processManager.workingDir = k.resolve(
4401
- r,
4392
+ t,
4402
4393
  e.tools.processManager.workingDir || ""
4403
4394
  )), e.tools?.fsManager && (e.tools.fsManager.workingDir = k.resolve(
4404
- r,
4395
+ t,
4405
4396
  e.tools.fsManager.workingDir || ""
4406
4397
  )), e.tools?.fsManager && (e.tools.fsManager.globsExclude = [
4407
4398
  {
@@ -4411,34 +4402,34 @@ This file contains glob patterns for files/directories to exclude from MCP opera
4411
4402
  },
4412
4403
  ...e.tools.fsManager.globsExclude || []
4413
4404
  ]), e.tools.fsManager?.globsExclude?.forEach((n, i, a) => {
4414
- n.valueType === "file-contains-patterns" && (a[i].value = k.resolve(r, n.value));
4415
- }), e.logDir = k.resolve(r, e.logDir), e;
4405
+ n.valueType === "file-contains-patterns" && (a[i].value = k.resolve(t, n.value));
4406
+ }), e.logDir = k.resolve(t, e.logDir), e;
4416
4407
  }
4417
4408
  function Vt() {
4418
4409
  return `mcp_${(/* @__PURE__ */ new Date()).toISOString().substring(0, 19).replace(/T/, "_").replace(/:/g, "-")}.log`;
4419
4410
  }
4420
- function Mo(t) {
4421
- const r = ne(), s = To();
4422
- return r.use(s), r;
4411
+ function Mo(r) {
4412
+ const t = ne(), s = To();
4413
+ return t.use(s), t;
4423
4414
  }
4424
- function To(t) {
4425
- const r = ne.Router();
4426
- return r.use((s, o, e) => {
4415
+ function To(r) {
4416
+ const t = ne.Router();
4417
+ return t.use((s, o, e) => {
4427
4418
  s.method === "OPTIONS" ? o.status(403).send("CORS forbidden") : e();
4428
- }), r.use(ne.json()), r;
4419
+ }), t.use(ne.json()), t;
4429
4420
  }
4430
- function Co(t) {
4431
- const r = ne.Router();
4432
- return r.use(pr({ authToken: t.authToken })), r.all("/mcp", yr(t)), r;
4421
+ function Co(r) {
4422
+ const t = ne.Router();
4423
+ return t.use(pr({ authToken: r.authToken })), t.all("/mcp", yr(r)), t;
4433
4424
  }
4434
- function vo(t, r) {
4435
- return t.use(So({ logFilePath: r.logFilePath })), new Promise((s, o) => {
4425
+ function vo(r, t) {
4426
+ return r.use(So({ logFilePath: t.logFilePath })), new Promise((s, o) => {
4436
4427
  let e;
4437
4428
  const n = () => {
4438
4429
  s(e);
4439
4430
  };
4440
4431
  try {
4441
- e = r.host ? t.listen(r.port ?? 0, r.host, n) : t.listen(r.port ?? 0, n), e.addListener("error", (i) => {
4432
+ e = t.host ? r.listen(t.port ?? 0, t.host, n) : r.listen(t.port ?? 0, n), e.addListener("error", (i) => {
4442
4433
  o(i);
4443
4434
  });
4444
4435
  } catch (i) {
@@ -4446,40 +4437,40 @@ function vo(t, r) {
4446
4437
  }
4447
4438
  });
4448
4439
  }
4449
- function Eo(t, r) {
4450
- if (!t.address())
4440
+ function Eo(r, t) {
4441
+ if (!r.address())
4451
4442
  throw new Error(
4452
4443
  "Server address is not available. Check your DNS and host configuration."
4453
4444
  );
4454
- const o = t.address().family, e = t.address().port;
4455
- let n = t.address().address;
4445
+ const o = r.address().family, e = r.address().port;
4446
+ let n = r.address().address;
4456
4447
  n === "::" ? n = "localhost" : o === "IPv6" && (n = `[${n}]`);
4457
4448
  const i = `http://${o === "IPv6" ? `[${n}]` : n}:${e}`;
4458
4449
  return `Project Tools - MCP Server Started
4459
4450
 
4460
- Server Name: ${r.name}
4461
- Server Version: ${r.version}
4451
+ Server Name: ${t.name}
4452
+ Server Version: ${t.version}
4462
4453
  Server URL: ${i}/mcp
4463
4454
  SSE Endpoint: ${i}/sse
4464
4455
 
4465
- Log File: ${k.resolve(r.logFilePath)}`;
4456
+ Log File: ${k.resolve(t.logFilePath)}`;
4466
4457
  }
4467
- function No(t, r) {
4468
- const s = k.join(r.logDir, Vt()), o = Jr(t, {
4458
+ function No(r, t) {
4459
+ const s = k.join(t.logDir, Vt()), o = Jr(r, {
4469
4460
  logFilePath: s
4470
4461
  });
4471
- r.tools.processManager && Gr(
4462
+ t.tools.processManager && Gr(
4472
4463
  o,
4473
- r.tools.processManager
4474
- ), r.tools.fsManager && Js(o, r.tools.fsManager), r.tools.playwrightManager && bo(
4464
+ t.tools.processManager
4465
+ ), t.tools.fsManager && Js(o, t.tools.fsManager), t.tools.playwrightManager && bo(
4475
4466
  o,
4476
- r.tools.playwrightManager
4467
+ t.tools.playwrightManager
4477
4468
  ), Pr(o);
4478
4469
  }
4479
- async function Yo(t) {
4480
- const r = k.join(t.logDir, Vt()), s = Mo(), o = Co({
4481
- authToken: t.authToken,
4482
- logFilePath: r,
4470
+ async function Yo(r) {
4471
+ const t = k.join(r.logDir, Vt()), s = Mo(), o = Co({
4472
+ authToken: r.authToken,
4473
+ logFilePath: t,
4483
4474
  createMcpServer: async (n) => {
4484
4475
  const i = n.headers["x-project-name"];
4485
4476
  if (!i)
@@ -4493,33 +4484,33 @@ X-Project-Name header is missing. To configure MCP for this project:
4493
4484
  4. Create .mcp.json in project root with X-Project-Name header set to project name
4494
4485
  5. Ask user to add project to server's projects config if not already present
4495
4486
  6. Ask user to restart Claude Code`);
4496
- const a = t.projects[i];
4487
+ const a = r.projects[i];
4497
4488
  if (!a)
4498
4489
  throw new Error(`MCP Error: Project "${i}" not found in server configuration.
4499
4490
 
4500
4491
  Ask user to:
4501
4492
  1. Add project to server's projects config: projects: { "${i}": "<project-path>" }
4502
4493
  2. Restart MCP server`);
4503
- const c = await Io(a), l = new Zt({
4504
- title: t.title,
4505
- name: t.name,
4506
- version: t.version
4494
+ const c = await $o(a), l = new Zt({
4495
+ title: r.title,
4496
+ name: r.name,
4497
+ version: r.version
4507
4498
  });
4508
4499
  return No(l, c), l;
4509
4500
  }
4510
4501
  });
4511
4502
  s.use(o);
4512
4503
  const e = await vo(s, {
4513
- host: t.host,
4514
- port: t.port,
4515
- logFilePath: r
4504
+ host: r.host,
4505
+ port: r.port,
4506
+ logFilePath: t
4516
4507
  });
4517
4508
  return console.log(
4518
4509
  Eo(e, {
4519
- title: t.title,
4520
- name: t.name,
4521
- version: t.version,
4522
- logFilePath: r
4510
+ title: r.title,
4511
+ name: r.name,
4512
+ version: r.version,
4513
+ logFilePath: t
4523
4514
  })
4524
4515
  ), e;
4525
4516
  }