@flemist/mcp-project-tools 4.0.2 → 4.0.3

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.
@@ -1,50 +1,50 @@
1
1
  import ne from "express";
2
- import { McpServer as Kt } from "@modelcontextprotocol/sdk/server/mcp.js";
3
- import { randomUUID as Ht } from "crypto";
2
+ import { McpServer as Vt } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { randomUUID as Zt } from "crypto";
4
4
  import * as j from "fs";
5
5
  import * as k from "path";
6
- import { StreamableHTTPServerTransport as Qt } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
7
- import { spawn as Yt } from "child_process";
8
- import { z as m } from "zod";
6
+ import { StreamableHTTPServerTransport as Xt } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
7
+ import { spawn as er } from "child_process";
8
+ import { z as h } from "zod";
9
9
  import he from "tree-kill";
10
- import { Pool as Vt, poolRunWait as V } from "@flemist/time-limits";
10
+ import { Pool as tr, poolRunWait as V } from "@flemist/time-limits";
11
11
  import { priorityCreate as X } from "@flemist/priority-queue";
12
- import { useAbortController as Zt, combineAbortSignals as Xt, Locker as er } from "@flemist/async-utils";
13
- import tr from "node:os";
14
- import rr from "picomatch";
15
- import { webkit as sr, firefox as or, chromium as nr } from "playwright";
16
- import ir from "deepmerge";
12
+ import { useAbortController as rr, combineAbortSignals as sr, Locker as or } from "@flemist/async-utils";
13
+ import nr from "node:os";
14
+ import ir from "picomatch";
15
+ import { webkit as ar, firefox as lr, chromium as cr } from "playwright";
16
+ import ur from "deepmerge";
17
17
  import Ne from "json5";
18
- import ar from "js-yaml";
19
- function lr(r) {
20
- const { authToken: t } = r;
18
+ import dr from "js-yaml";
19
+ function fr(t) {
20
+ const { authToken: r } = t;
21
21
  return function(o, e, n) {
22
- if ((o.query.token || o.headers.authorization?.replace("Bearer ", "")) !== t) {
22
+ if ((o.query.token || o.headers.authorization?.replace("Bearer ", "")) !== r) {
23
23
  e.status(401).json({ error: "Unauthorized" });
24
24
  return;
25
25
  }
26
26
  n();
27
27
  };
28
28
  }
29
- async function ie(r) {
30
- const { logFilePath: t, message: s, data: o } = r;
29
+ async function ie(t) {
30
+ const { logFilePath: r, message: s, data: o } = t;
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(t), { recursive: !0 }), await j.promises.appendFile(t, i);
36
+ await j.promises.mkdir(k.dirname(r), { recursive: !0 }), await j.promises.appendFile(r, 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 cr(r) {
43
- return r.headers["mcp-session-id"] || r.headers["x-session-id"] || r.query.token;
42
+ function pr(t) {
43
+ return t.headers["mcp-session-id"] || t.headers["x-session-id"] || t.query.token;
44
44
  }
45
- async function ur(r, t) {
46
- const s = await t.createMcpServer(r), o = new Qt({
47
- sessionIdGenerator: Ht,
45
+ async function hr(t, r) {
46
+ const s = await r.createMcpServer(t), o = new Xt({
47
+ sessionIdGenerator: Zt,
48
48
  onsessioninitialized: (n) => {
49
49
  ae.set(n, o);
50
50
  },
@@ -66,28 +66,28 @@ async function ur(r, t) {
66
66
  throw await e(), n;
67
67
  }
68
68
  }
69
- async function dr(r, t, s, o) {
69
+ async function mr(t, r, s, o) {
70
70
  await ie({
71
71
  logFilePath: s.logFilePath,
72
72
  message: "REQUEST",
73
- data: r.body
73
+ data: t.body
74
74
  });
75
75
  let e = o ? ae.get(o) : null;
76
- e || (e = await ur(r, s)), await e.handleRequest(r, t, r.body);
76
+ e || (e = await hr(t, s)), await e.handleRequest(t, r, t.body);
77
77
  }
78
- async function fr(r, t, s) {
78
+ async function gr(t, r, s) {
79
79
  const o = s ? ae.get(s) : null;
80
80
  if (!o) {
81
- t.status(400).json({ error: "No valid session found" });
81
+ r.status(400).json({ error: "No valid session found" });
82
82
  return;
83
83
  }
84
- await o.handleRequest(r, t);
84
+ await o.handleRequest(t, r);
85
85
  }
86
- function pr(r) {
86
+ function wr(t) {
87
87
  return async function(s, o) {
88
88
  try {
89
- const e = cr(s);
90
- s.method === "POST" ? await dr(s, o, r, e) : s.method === "GET" ? await fr(s, o, e) : o.status(405).json({ error: "Method not allowed" });
89
+ const e = pr(s);
90
+ s.method === "POST" ? await mr(s, o, t, e) : s.method === "GET" ? await gr(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")
@@ -96,13 +96,13 @@ function pr(r) {
96
96
  };
97
97
  }
98
98
  const Y = /* @__PURE__ */ new Map();
99
- let hr = 0;
100
- const ke = 10, mr = 1800 * 1e3, J = 1e4, Q = 2e3, gr = 5e3;
101
- function wr(r) {
102
- const { commandLine: t, commandLineRules: s } = r;
99
+ let yr = 0;
100
+ const ke = 10, br = 1800 * 1e3, J = 1e4, Q = 2e3, Sr = 5e3;
101
+ function xr(t) {
102
+ const { commandLine: r, commandLineRules: s } = t;
103
103
  let o = !1;
104
104
  for (const e of s)
105
- if (new RegExp(e.regexp).test(t))
105
+ if (new RegExp(e.regexp).test(r))
106
106
  switch (e.rule) {
107
107
  case "allow":
108
108
  o = !0;
@@ -115,65 +115,101 @@ function wr(r) {
115
115
  }
116
116
  return o;
117
117
  }
118
- function yr() {
119
- return ++hr;
118
+ function $r() {
119
+ return ++yr;
120
120
  }
121
121
  let Oe = !1;
122
- function br() {
122
+ function Ir() {
123
123
  if (Oe)
124
124
  return;
125
125
  Oe = !0;
126
- const r = () => {
126
+ const t = () => {
127
127
  console.log("Auto-killing all child processes...");
128
- for (const [t, s] of Array.from(Y.entries()))
128
+ for (const [r, 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 ${t}:`, o);
133
+ console.error(`Error killing process ${r}:`, o);
134
134
  }
135
135
  process.exit(0);
136
136
  };
137
- process.on("SIGINT", r), process.on("SIGTERM", r);
137
+ process.on("SIGINT", t), process.on("SIGTERM", t);
138
138
  }
139
139
  function ge() {
140
- const r = Date.now(), t = [];
140
+ const t = Date.now(), r = [];
141
141
  for (const [s, o] of Array.from(Y.entries()))
142
- !o.isRunning && o.endTime && r - o.endTime.getTime() > mr && t.push(s);
143
- for (const s of t)
142
+ !o.isRunning && o.endTime && t - o.endTime.getTime() > br && r.push(s);
143
+ for (const s of r)
144
144
  Y.delete(s);
145
145
  }
146
- const Sr = 1800 * 1e3, De = /* @__PURE__ */ new Map();
147
- let xr = 0;
148
- function $r() {
149
- return ++xr;
146
+ function Re(t) {
147
+ return t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
150
148
  }
151
- function ot(r) {
152
- let t = De.get(r);
153
- return t == null && (t = {
149
+ const De = "[/\\\\]";
150
+ function at(t, r) {
151
+ const s = t.replace(/[\\/]+$/, "");
152
+ let o;
153
+ return r ? o = s.split(/[\\/]/).map(Re).join(De) : o = Re(s), o += `(?=${De}|$)`, new RegExp(o, r ? "gi" : "g");
154
+ }
155
+ function Mr(t, r, s, o) {
156
+ const e = at(r, o);
157
+ return t.replace(e, (n) => s + n.slice(r.length));
158
+ }
159
+ function Tr(t, r, s, o) {
160
+ const e = process.platform === "win32", n = {};
161
+ if (s !== "clear") if (s === "replaceServerPaths" || s === "deleteServerPaths") {
162
+ const i = Fe(t, e), a = Fe(r, e);
163
+ if (i !== a) {
164
+ const l = at(t, e);
165
+ for (const [u, f] of Object.entries(process.env))
166
+ f != null && (l.lastIndex = 0, l.test(f) ? s === "replaceServerPaths" && (n[u] = Mr(f, t, r, e)) : n[u] = f);
167
+ } else
168
+ for (const [l, u] of Object.entries(process.env))
169
+ u != null && (n[l] = u);
170
+ } else
171
+ for (const [i, a] of Object.entries(process.env))
172
+ a != null && (n[i] = a);
173
+ if (o)
174
+ for (const [i, a] of Object.entries(o))
175
+ a === null ? delete n[i] : n[i] = a;
176
+ return n;
177
+ }
178
+ function Fe(t, r) {
179
+ const s = k.normalize(t).replace(/[\\/]+$/, "");
180
+ return r ? s.toLowerCase() : s;
181
+ }
182
+ const Cr = 1800 * 1e3, Be = /* @__PURE__ */ new Map();
183
+ let vr = 0;
184
+ function Er() {
185
+ return ++vr;
186
+ }
187
+ function lt(t) {
188
+ let r = Be.get(t);
189
+ return r == null && (r = {
154
190
  storedOutputs: /* @__PURE__ */ new Map()
155
- }, De.set(r, t)), t;
191
+ }, Be.set(t, r)), r;
156
192
  }
157
- function nt(r) {
158
- return typeof r == "function" ? r() : r;
193
+ function ct(t) {
194
+ return typeof t == "function" ? t() : t;
159
195
  }
160
- function it(r, t) {
196
+ function ut(t, r) {
161
197
  return setTimeout(() => {
162
- r.storedOutputs.delete(t);
163
- }, Sr);
198
+ t.storedOutputs.delete(r);
199
+ }, Cr);
164
200
  }
165
- function Ir(r, t, s) {
166
- clearTimeout(s.cleanupTimer), s.cleanupTimer = it(r, t);
201
+ function Nr(t, r, s) {
202
+ clearTimeout(s.cleanupTimer), s.cleanupTimer = ut(t, r);
167
203
  }
168
- function Mr(r) {
169
- const { sessionId: t, source: s } = r, o = ot(t), e = $r(), n = {
204
+ function kr(t) {
205
+ const { sessionId: r, source: s } = t, o = lt(r), e = Er(), n = {
170
206
  source: s,
171
- cleanupTimer: it(o, e)
207
+ cleanupTimer: ut(o, e)
172
208
  };
173
209
  return o.storedOutputs.set(e, n), e;
174
210
  }
175
- function at(r) {
176
- const { sessionId: t, outputId: s, range: o } = r, [e, n] = o, i = ot(t), a = i.storedOutputs.get(s);
211
+ function dt(t) {
212
+ const { sessionId: r, outputId: s, range: o } = t, [e, n] = o, i = lt(r), a = i.storedOutputs.get(s);
177
213
  if (a == null)
178
214
  return {
179
215
  content: "",
@@ -181,16 +217,16 @@ function at(r) {
181
217
  range: [0, 0],
182
218
  error: `Stored output with outputId=${s} not found or expired`
183
219
  };
184
- Ir(i, s, a);
185
- const c = nt(a.source), l = c.length, u = Math.min(Math.max(e, 0), l), f = Math.min(Math.max(n, 0), l);
220
+ Nr(i, s, a);
221
+ const c = ct(a.source), l = c.length, u = Math.min(Math.max(e, 0), l), f = Math.min(Math.max(n, 0), l);
186
222
  return { content: c.substring(u, f), total: l, range: [u, f] };
187
223
  }
188
- function we(r) {
189
- const { sessionId: t, source: s, limit: o } = r, e = nt(s);
224
+ function we(t) {
225
+ const { sessionId: r, source: s, limit: o } = t, e = ct(s);
190
226
  if (e.length <= o)
191
227
  return { content: e, outputId: null };
192
- const n = Mr({ sessionId: t, source: s }), i = at({
193
- sessionId: t,
228
+ const n = kr({ sessionId: r, source: s }), i = dt({
229
+ sessionId: r,
194
230
  outputId: n,
195
231
  range: [0, o]
196
232
  }), a = `
@@ -200,27 +236,27 @@ function we(r) {
200
236
  outputId: n
201
237
  };
202
238
  }
203
- function F(r) {
204
- return `Invalid arguments: ${r instanceof Error ? r.message : "Unknown error"}.
239
+ function F(t) {
240
+ return `Invalid arguments: ${t instanceof Error ? t.message : "Unknown error"}.
205
241
 
206
242
  Provide valid parameters according to schema.`;
207
243
  }
208
- const lt = m.object({
209
- outputId: m.number().int().describe("Output ID from truncation message"),
210
- range: m.tuple([m.number().int().min(0), m.number().int().min(0)]).describe(
244
+ const ft = h.object({
245
+ outputId: h.number().int().describe("Output ID from truncation message"),
246
+ range: h.tuple([h.number().int().min(0), h.number().int().min(0)]).describe(
211
247
  `Character range [from, to) to retrieve. Maximum range size: ${J}.`
212
248
  )
213
249
  });
214
- function Tr(r, t) {
250
+ function Or(t, r) {
215
251
  let s;
216
252
  try {
217
- s = lt.parse(r);
253
+ s = ft.parse(t);
218
254
  } catch (i) {
219
255
  return {
220
256
  error: F(i)
221
257
  };
222
258
  }
223
- if (!t.sessionId)
259
+ if (!r.sessionId)
224
260
  return {
225
261
  error: "Session ID is required"
226
262
  };
@@ -233,28 +269,28 @@ function Tr(r, t) {
233
269
  return {
234
270
  error: `Range size ${e - o} exceeds maximum ${J}`
235
271
  };
236
- const n = at({
237
- sessionId: t.sessionId,
272
+ const n = dt({
273
+ sessionId: r.sessionId,
238
274
  outputId: s.outputId,
239
275
  range: s.range
240
276
  });
241
277
  return n.error != null ? { error: n.error } : { content: n.content, total: n.total, range: n.range };
242
278
  }
243
- function Cr(r) {
244
- r(
279
+ function Rr(t) {
280
+ t(
245
281
  "output-read",
246
282
  {
247
283
  title: "Read Stored Output Range",
248
284
  description: "Read any range from stored output. Use outputId from truncation message and specify character range [from, to).",
249
- inputSchema: lt.shape
285
+ inputSchema: ft.shape
250
286
  },
251
- async (t, s) => {
252
- const o = Tr(t, s);
287
+ async (r, s) => {
288
+ const o = Or(r, s);
253
289
  if (o.error != null)
254
- return `Method: output-read(${JSON.stringify(t)})
290
+ return `Method: output-read(${JSON.stringify(r)})
255
291
  ❌ Error: ${o.error}`;
256
292
  const [e, n] = o.range, i = o.total;
257
- let a = `Method: output-read(${JSON.stringify(t)})
293
+ let a = `Method: output-read(${JSON.stringify(r)})
258
294
  showing [${e}, ${n}) of ${i} chars`;
259
295
  return e >= i && (a += `
260
296
  ⚠️ Warning: requested range is beyond content (total: ${i} chars)`), a += `
@@ -263,22 +299,22 @@ ${o.content}`, a;
263
299
  }
264
300
  );
265
301
  }
266
- function Er(r) {
267
- Cr(r);
302
+ function Dr(t) {
303
+ Rr(t);
268
304
  }
269
- const ct = m.object({
270
- id: m.number().describe(
305
+ const pt = h.object({
306
+ id: h.number().describe(
271
307
  "Process ID to get detailed status information for. Get process IDs using process-list. Works for both running and completed processes. Examples: 1, 42, 123"
272
308
  ),
273
- outputLimit: m.number().int().min(0).max(J).default(Q).describe(
309
+ outputLimit: h.number().int().min(0).max(J).default(Q).describe(
274
310
  `Maximum output characters to return. Truncated output can be retrieved via output-read tool using outputId from truncation message. Maximum: ${J}. Default: ${Q}`
275
311
  )
276
312
  });
277
- async function ye(r, t, s) {
313
+ async function ye(t, r, s) {
278
314
  ge();
279
315
  let o;
280
316
  try {
281
- o = ct.parse(r);
317
+ o = pt.parse(t);
282
318
  } catch (c) {
283
319
  return {
284
320
  error: F(c)
@@ -300,7 +336,7 @@ async function ye(r, t, s) {
300
336
  }).content;
301
337
  return {
302
338
  id: i.id,
303
- cwd: k.relative(t.workingDir || "", i.cwd),
339
+ cwd: k.relative(r.workingDir || "", i.cwd),
304
340
  commandLine: i.commandLine,
305
341
  pid: i.pid,
306
342
  startTime: i.startTime.toISOString().replace(/[TZ]/g, " ").trim(),
@@ -311,16 +347,16 @@ async function ye(r, t, s) {
311
347
  error: i.error
312
348
  };
313
349
  }
314
- function vr(r, t) {
315
- r(
350
+ function Fr(t, r) {
351
+ t(
316
352
  "process-status",
317
353
  {
318
354
  title: "Get Host Machine Process Status",
319
355
  description: "Get detailed status information about a process on the host machine. Use this to check if commands completed successfully, get their output, or monitor running processes",
320
- inputSchema: ct.shape
356
+ inputSchema: pt.shape
321
357
  },
322
358
  async (s, o) => {
323
- const e = await ye(s, t, o);
359
+ const e = await ye(s, r, o);
324
360
  if (!("output" in e))
325
361
  return `Method: process-status(${JSON.stringify(s)})
326
362
  ❌ Error: ${e.error}`;
@@ -333,36 +369,36 @@ ${n.trim()}`;
333
369
  }
334
370
  );
335
371
  }
336
- function ut(r) {
337
- he(r, "SIGTERM", (t) => {
338
- t && !t.message.includes("not found") && console.error(`Error sending SIGTERM to process ${r}:`, t);
372
+ function ht(t) {
373
+ he(t, "SIGTERM", (r) => {
374
+ r && !r.message.includes("not found") && console.error(`Error sending SIGTERM to process ${t}:`, r);
339
375
  }), setTimeout(() => {
340
- he(r, "SIGKILL", (t) => {
341
- t && !t.message.includes("not found") && console.error(`Error sending SIGKILL to process ${r}:`, t);
376
+ he(t, "SIGKILL", (r) => {
377
+ r && !r.message.includes("not found") && console.error(`Error sending SIGKILL to process ${t}:`, r);
342
378
  });
343
- }, gr);
379
+ }, Sr);
344
380
  }
345
- const dt = m.object({
346
- id: m.number().describe(
381
+ const mt = h.object({
382
+ id: h.number().describe(
347
383
  "Process ID to wait for completion. Get process IDs using process-list. The process can be running or already completed. Examples: 1, 42, 123"
348
384
  ),
349
- waitTime: m.number().optional().describe(
385
+ waitTime: h.number().optional().describe(
350
386
  "Maximum time to wait in seconds for process completion. If omitted, waits indefinitely until process completes. If process is already completed, returns immediately. Examples: 30 (wait up to 30 seconds), 300 (wait up to 5 minutes)"
351
387
  ),
352
- autoKill: m.boolean().default(!1).describe(
388
+ autoKill: h.boolean().default(!1).describe(
353
389
  "Automatically terminate the process if waitTime expires and it is still running. Only applies when waitTime is specified. Default: false (let process continue running after timeout). Set to true for processes that should not run indefinitely"
354
390
  ),
355
- outputLimit: m.number().int().min(0).max(J).default(Q).describe(
391
+ outputLimit: h.number().int().min(0).max(J).default(Q).describe(
356
392
  `Maximum output characters to return. Truncated output can be retrieved via output-read tool using outputId from truncation message. Maximum: ${J}. Default: ${Q}`
357
393
  )
358
394
  });
359
- async function ft(r, t, s) {
395
+ async function gt(t, r, s) {
360
396
  let o;
361
397
  try {
362
- o = dt.parse(r);
363
- } catch (h) {
398
+ o = mt.parse(t);
399
+ } catch (m) {
364
400
  return {
365
- error: F(h)
401
+ error: F(m)
366
402
  };
367
403
  }
368
404
  const { id: e, waitTime: n, autoKill: i, outputLimit: a } = o, c = Y.get(e);
@@ -374,27 +410,27 @@ async function ft(r, t, s) {
374
410
  let u = !1, f = !1;
375
411
  n != null && await new Promise((g) => {
376
412
  const y = setInterval(() => {
377
- c.isRunning ? Date.now() - l >= n * 1e3 && (clearInterval(y), u = !0, i && c.pid && (ut(c.pid), f = !0), g()) : (clearInterval(y), g());
413
+ c.isRunning ? Date.now() - l >= n * 1e3 && (clearInterval(y), u = !0, i && c.pid && (ht(c.pid), f = !0), g()) : (clearInterval(y), g());
378
414
  }, 100);
379
415
  });
380
416
  const d = (Date.now() - l) / 1e3;
381
417
  return {
382
- ...await ye({ id: e, outputLimit: a }, t, s),
418
+ ...await ye({ id: e, outputLimit: a }, r, s),
383
419
  waitDuration: d,
384
420
  waitTimeExceeded: u,
385
421
  autoKillExecuted: f
386
422
  };
387
423
  }
388
- function Nr(r, t) {
389
- r(
424
+ function Br(t, r) {
425
+ t(
390
426
  "process-wait",
391
427
  {
392
428
  title: "Wait for Host Machine Process",
393
429
  description: "Wait for a host machine process to complete execution, with optional timeout and auto-kill functionality. Use this for long-running commands like builds, installs, or tests when you need final results",
394
- inputSchema: dt.shape
430
+ inputSchema: mt.shape
395
431
  },
396
432
  async (s, o) => {
397
- const e = await ft(s, t, o);
433
+ const e = await gt(s, r, o);
398
434
  if (!("output" in e))
399
435
  return `Method: process-wait(${JSON.stringify(s)})
400
436
  ❌ Error: ${e.error}`;
@@ -407,73 +443,72 @@ ${n.trim()}`;
407
443
  }
408
444
  );
409
445
  }
410
- function H(r) {
411
- return r.replace(/\\/g, "/");
446
+ function H(t) {
447
+ return t.replace(/\\/g, "/");
412
448
  }
413
- function be(r, t) {
414
- const s = H(k.resolve(r)), o = H(
415
- k.resolve(r, t || "")
449
+ function be(t, r) {
450
+ if (!t)
451
+ return { error: "Working directory is not configured" };
452
+ const s = H(k.resolve(t)), o = H(
453
+ k.resolve(t, r || "")
416
454
  );
417
455
  return !o.startsWith(s + "/") && o !== s ? {
418
- error: `Path "${t}" escapes root directory "${r}". Resolved path: "${o}"`
456
+ error: `Path "${r}" escapes root directory "${t}". Resolved path: "${o}"`
419
457
  } : { path: o };
420
458
  }
421
- const pt = m.object({
422
- relativeRootDir: m.string().optional().describe(
459
+ const wt = h.object({
460
+ relativeRootDir: h.string().optional().describe(
423
461
  'Relative path from project root to working directory for command execution. Use forward slashes. Leave empty for project root. Examples: "src", "src/tools", "tests/unit". Directory must exist'
424
462
  ),
425
- commandLine: m.string().describe(
463
+ commandLine: h.string().describe(
426
464
  'Complete command line to execute on the host machine. Include all arguments and options. Examples: "npm install", "pnpm build", "node script.js --verbose", "git status". Command must be in the allowed commands list for security'
427
465
  ),
428
- waitTime: m.number().optional().describe(
466
+ waitTime: h.number().optional().describe(
429
467
  "Time to wait in seconds for process completion before returning results. If specified, will wait this long then return final status. If omitted, returns immediately with initial status. Use process-wait or process-status to check progress later. Examples: 30 (wait 30 seconds), 120 (wait 2 minutes)"
430
468
  ),
431
- autoKill: m.boolean().default(!1).describe(
469
+ autoKill: h.boolean().default(!1).describe(
432
470
  "Automatically kill the process if waitTime expires and it is still running. Only applies when waitTime is specified. Default: false (let process continue running). Set to true for commands that should not run indefinitely"
433
471
  ),
434
- outputLimit: m.number().int().min(0).max(J).default(Q).describe(
472
+ outputLimit: h.number().int().min(0).max(J).default(Q).describe(
435
473
  `Maximum output characters to return. Truncated output can be retrieved via output-read tool using outputId from truncation message. Maximum: ${J}. Default: ${Q}`
436
474
  )
437
475
  });
438
- async function kr(r, t, s) {
476
+ async function Lr(t, r, s) {
439
477
  ge();
440
478
  let o;
441
479
  try {
442
- o = pt.parse(r);
443
- } catch (h) {
480
+ o = wt.parse(t);
481
+ } catch (m) {
444
482
  return {
445
- error: F(h)
483
+ error: F(m)
446
484
  };
447
485
  }
448
- const { commandLine: e, waitTime: n, autoKill: i, outputLimit: a } = o, { commandLineRules: c } = t;
449
- if (!t.workingDir)
450
- return { error: "Working directory is not configured" };
451
- const l = be(
452
- t.workingDir,
486
+ const { commandLine: e, waitTime: n, autoKill: i, outputLimit: a } = o, { commandLineRules: c } = r, l = be(
487
+ r.workingDir,
453
488
  o.relativeRootDir
454
489
  );
455
490
  if ("error" in l)
456
491
  return { error: l.error };
457
492
  const u = l.path;
458
- if (!wr({ commandLine: e, commandLineRules: c })) {
459
- const h = c.map(
493
+ if (!xr({ commandLine: e, commandLineRules: c })) {
494
+ const m = c.map(
460
495
  (g) => `${g.rule.toUpperCase()}: /${g.regexp}/ (${g.note})`
461
496
  ).join(`
462
497
  `);
463
498
  return {
464
499
  error: `Command line not allowed: "${e}". For security, command lines are validated against configured rules in order. Command line was denied by the rule evaluation. Current command line rules:
465
- ${h}
500
+ ${m}
466
501
 
467
502
  To use this command line, ask the user to modify the command line rules in the configuration.`
468
503
  };
469
504
  }
470
505
  if (Array.from(Y.values()).filter(
471
- (h) => h.isRunning
506
+ (m) => m.isRunning
472
507
  ).length >= ke)
473
508
  return {
474
509
  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.`
475
510
  };
476
- const d = yr(), p = {
511
+ const d = $r(), p = {
477
512
  id: d,
478
513
  cwd: u,
479
514
  commandLine: e,
@@ -483,42 +518,48 @@ To use this command line, ask the user to modify the command line rules in the c
483
518
  };
484
519
  Y.set(d, p);
485
520
  try {
486
- const h = Yt(e, [], {
521
+ const m = Tr(
522
+ process.cwd(),
523
+ u,
524
+ r.envCleanup ?? null,
525
+ r.env
526
+ ), g = er(e, [], {
487
527
  shell: !0,
488
528
  cwd: u,
529
+ env: m,
489
530
  stdio: ["pipe", "pipe", "pipe"]
490
531
  });
491
- p.pid = h.pid;
492
- const g = (y) => {
493
- const w = y.toString();
494
- p.output += w, console.log(w);
532
+ p.pid = g.pid;
533
+ const y = (w) => {
534
+ const M = w.toString();
535
+ p.output += M, console.log(M);
495
536
  };
496
- return h.stdout?.on("data", g), h.stderr?.on("data", g), h.on("close", (y) => {
497
- p.isRunning = !1, p.endTime = /* @__PURE__ */ new Date(), p.exitCode = y !== null ? y : void 0, console.log(`Process ${d} (${e}) exited with code ${y}`);
498
- }), h.on("error", (y) => {
499
- p.isRunning = !1, p.endTime = /* @__PURE__ */ new Date(), p.error = y.message, console.error(`Process ${d} error:`, y.message);
500
- }), n != null ? ft(
537
+ return g.stdout?.on("data", y), g.stderr?.on("data", y), g.on("close", (w) => {
538
+ p.isRunning = !1, p.endTime = /* @__PURE__ */ new Date(), p.exitCode = w !== null ? w : void 0, console.log(`Process ${d} (${e}) exited with code ${w}`);
539
+ }), g.on("error", (w) => {
540
+ p.isRunning = !1, p.endTime = /* @__PURE__ */ new Date(), p.error = w.message, console.error(`Process ${d} error:`, w.message);
541
+ }), n != null ? gt(
501
542
  { id: d, waitTime: n, autoKill: i, outputLimit: a },
502
- t,
543
+ r,
503
544
  s
504
- ) : ye({ id: d, outputLimit: a }, t, s);
505
- } catch (h) {
506
- return p.isRunning = !1, p.endTime = /* @__PURE__ */ new Date(), p.error = h instanceof Error ? h.message : "Unknown error", { error: p.error };
545
+ ) : ye({ id: d, outputLimit: a }, r, s);
546
+ } catch (m) {
547
+ return p.isRunning = !1, p.endTime = /* @__PURE__ */ new Date(), p.error = m instanceof Error ? m.message : "Unknown error", { error: p.error };
507
548
  }
508
549
  }
509
- function Or(r, t) {
510
- const s = t.commandLineRules.map((o) => `${o.rule.toUpperCase()}: ${o.regexp} (${o.note})`).join(`
550
+ function Pr(t, r) {
551
+ const s = r.commandLineRules.map((o) => `${o.rule.toUpperCase()}: ${o.regexp} (${o.note})`).join(`
511
552
  `);
512
- r(
553
+ t(
513
554
  "process-run",
514
555
  {
515
556
  title: "Execute Command Line on Host Machine",
516
557
  description: `Execute command lines on the host machine. Use this to build, test, lint, install packages, or run system commands. Prefer process-run with waitTime parameter if you need to immediately execute and wait for completion, instead of separate process-run and process-wait calls. Security: Command lines are validated against configured rules processed in order (later rules override earlier ones). Current command line rules:
517
558
  ${s}`,
518
- inputSchema: pt.shape
559
+ inputSchema: wt.shape
519
560
  },
520
561
  async (o, e) => {
521
- const n = await kr(o, t, e);
562
+ const n = await Lr(o, r, e);
522
563
  if (!("output" in n))
523
564
  return `Method: process-run(${JSON.stringify(o)})
524
565
  ❌ Error: ${n.error}`;
@@ -531,25 +572,25 @@ ${i.trim()}`;
531
572
  }
532
573
  );
533
574
  }
534
- const ht = m.object({
535
- minOpenDateTime: m.string().optional().describe(
575
+ const yt = h.object({
576
+ minOpenDateTime: h.string().optional().describe(
536
577
  'Filter to processes started after this datetime. Accepts ISO format or space-separated format. Examples: "2024-01-15T10:30:00Z", "2024-01-15 10:30:00". Underscores and spaces are converted to standard ISO format internally'
537
578
  ),
538
- minCloseDateTime: m.string().optional().describe(
579
+ minCloseDateTime: h.string().optional().describe(
539
580
  'Filter to processes that finished after this datetime. Only applies to completed processes. Accepts ISO format or space-separated format. Examples: "2024-01-15T14:30:00Z", "2024-01-15 14:30:00". Useful for finding recently completed processes'
540
581
  ),
541
- activeOnly: m.boolean().default(!1).describe(
582
+ activeOnly: h.boolean().default(!1).describe(
542
583
  "Show only currently running processes. Set to true to exclude completed processes, false to show all processes (running and completed). Default: false (show all)"
543
584
  ),
544
- fields: m.array(m.string()).optional().describe(
585
+ fields: h.array(h.string()).optional().describe(
545
586
  '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'
546
587
  )
547
588
  });
548
- async function Dr(r, t) {
589
+ async function Ar(t, r) {
549
590
  ge();
550
591
  let s;
551
592
  try {
552
- s = ht.parse(r);
593
+ s = yt.parse(t);
553
594
  } catch (l) {
554
595
  return {
555
596
  error: F(l)
@@ -568,7 +609,7 @@ async function Dr(r, t) {
568
609
  return n && (a = a.filter((l) => l.isRunning)), { processes: a.map((l) => {
569
610
  let u = {
570
611
  id: l.id,
571
- cwd: k.relative(t.workingDir || "", l.cwd),
612
+ cwd: k.relative(r.workingDir || "", l.cwd),
572
613
  commandLine: l.commandLine,
573
614
  pid: l.pid,
574
615
  startTime: l.startTime.toISOString().replace(/[TZ]/g, " ").trim(),
@@ -588,16 +629,16 @@ async function Dr(r, t) {
588
629
  return u;
589
630
  }) };
590
631
  }
591
- function Rr(r, t) {
592
- r(
632
+ function zr(t, r) {
633
+ t(
593
634
  "process-list",
594
635
  {
595
636
  title: "List Host Machine Processes",
596
637
  description: "List all processes that have been executed on the host machine. Use this to see running processes, check command history, or find process IDs for status/wait operations",
597
- inputSchema: ht.shape
638
+ inputSchema: yt.shape
598
639
  },
599
640
  async (s) => {
600
- const o = await Dr(s, t);
641
+ const o = await Ar(s, r);
601
642
  if (o.error != null)
602
643
  return `Method: process-list(${JSON.stringify(s)})
603
644
  ❌ Error: ${o.error}`;
@@ -611,21 +652,21 @@ ${e}`;
611
652
  }
612
653
  );
613
654
  }
614
- const mt = m.object({
615
- id: m.number().describe(
655
+ const bt = h.object({
656
+ id: h.number().describe(
616
657
  "Process ID of the process to terminate. Get process IDs using process-list. The process must be currently running. Examples: 1, 42, 123"
617
658
  )
618
659
  });
619
- function Fr(r) {
620
- let t;
660
+ function Ur(t) {
661
+ let r;
621
662
  try {
622
- t = mt.parse(r);
663
+ r = bt.parse(t);
623
664
  } catch (e) {
624
665
  return {
625
666
  error: F(e)
626
667
  };
627
668
  }
628
- const { id: s } = t, o = Y.get(s);
669
+ const { id: s } = r, o = Y.get(s);
629
670
  if (!o)
630
671
  return {
631
672
  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.`
@@ -639,54 +680,54 @@ function Fr(r) {
639
680
  error: `Process ${s} has no system process ID (PID). This indicates the process failed to start properly or the system was unable to assign a PID. Check process-status for error details.`
640
681
  };
641
682
  try {
642
- return ut(o.pid), { success: !0, message: `Kill signal sent to process ${s}` };
683
+ return ht(o.pid), { success: !0, message: `Kill signal sent to process ${s}` };
643
684
  } catch (e) {
644
685
  return {
645
686
  error: `Failed to terminate process ${s}: ${e instanceof Error ? e.message : "Unknown error"}. The process may have already exited, be protected by the system, or there may be insufficient permissions. Use process-status to check current process state.`
646
687
  };
647
688
  }
648
689
  }
649
- function Br(r, t) {
650
- r(
690
+ function jr(t, r) {
691
+ t(
651
692
  "process-kill",
652
693
  {
653
694
  title: "Kill Host Machine Process",
654
695
  description: "Forcibly terminate a running process on the host machine. Use this to stop runaway processes, hung commands, or long-running tasks that need to be cancelled",
655
- inputSchema: mt.shape
696
+ inputSchema: bt.shape
656
697
  },
657
698
  async (s) => {
658
- const o = Fr(s);
699
+ const o = Ur(s);
659
700
  return o.error != null ? `Method: process-kill(${JSON.stringify(s)})
660
701
  ❌ Error: ${o.error}` : `Method: process-kill(${JSON.stringify(s)})
661
702
  ${JSON.stringify(o, null, 2)}`;
662
703
  }
663
704
  );
664
705
  }
665
- function Lr(r, t) {
666
- br(), t.run && Or(r, t), t.status && vr(r, t), t.wait && Nr(r, t), t.list && Rr(r, t), t.kill && Br(r);
667
- const s = t.commandLineRules?.map(
706
+ function qr(t, r) {
707
+ Ir(), r.run && Pr(t, r), r.status && Fr(t, r), r.wait && Br(t, r), r.list && zr(t, r), r.kill && jr(t);
708
+ const s = r.commandLineRules?.map(
668
709
  (o) => `${o.rule.toUpperCase()}: ${o.regexp} (${o.note})`
669
710
  ) || [];
670
711
  console.log(
671
712
  `Process manager:
672
- - Working directory: ${k.resolve(t.workingDir || "")}
673
- - Command line rules: ${t.commandLineRules?.length || 0} rules configured:
713
+ - Working directory: ${k.resolve(r.workingDir || "")}
714
+ - Command line rules: ${r.commandLineRules?.length || 0} rules configured:
674
715
  ${s.map((o) => `- ${o}`).join(`
675
716
  `)}
676
717
  `
677
718
  );
678
719
  }
679
- function Pr(r, t) {
720
+ function _r(t, r) {
680
721
  return function(o, e, n) {
681
722
  const i = async (...a) => {
682
723
  await ie({
683
- logFilePath: t.logFilePath,
724
+ logFilePath: r.logFilePath,
684
725
  message: "REQUEST",
685
726
  data: { name: o, args: a }
686
727
  });
687
728
  const c = await n(...a);
688
729
  return await ie({
689
- logFilePath: t.logFilePath,
730
+ logFilePath: r.logFilePath,
690
731
  message: "RESPONSE",
691
732
  data: c
692
733
  }), {
@@ -698,35 +739,35 @@ function Pr(r, t) {
698
739
  ]
699
740
  };
700
741
  };
701
- return r.registerTool(
742
+ return t.registerTool(
702
743
  o,
703
744
  e,
704
745
  i
705
746
  );
706
747
  };
707
748
  }
708
- function Ar(r) {
709
- return r.match(/^[/\\]?[^/\\]+/)[0];
749
+ function Gr(t) {
750
+ return t.match(/^[/\\]?[^/\\]+/)[0];
710
751
  }
711
- function zr(r, t) {
712
- return Ar(r) + "|" + t.ino;
752
+ function Jr(t, r) {
753
+ return Gr(t) + "|" + r.ino;
713
754
  }
714
- function Ur(r) {
715
- return r.endsWith(":") && (r += "/"), k.resolve(r);
755
+ function Wr(t) {
756
+ return t.endsWith(":") && (t += "/"), k.resolve(t);
716
757
  }
717
- const Se = new Vt(tr.cpus().length);
718
- function Re(r, t) {
719
- r.totalSize += t.totalSize, r.maxFileDateModified = Math.max(
720
- r.maxFileDateModified,
721
- t.maxFileDateModified
722
- ), r.countFiles += t.countFiles, r.countDirs += t.countDirs, r.countLinks += t.countLinks;
758
+ const Se = new tr(nr.cpus().length);
759
+ function Le(t, r) {
760
+ t.totalSize += r.totalSize, t.maxFileDateModified = Math.max(
761
+ t.maxFileDateModified,
762
+ r.maxFileDateModified
763
+ ), t.countFiles += r.countFiles, t.countDirs += r.countDirs, t.countLinks += r.countLinks;
723
764
  }
724
- const jr = function(t) {
725
- return t.code === "ENOENT";
765
+ const Kr = function(r) {
766
+ return r.code === "ENOENT";
726
767
  };
727
- function gt(r) {
728
- const t = r.paths;
729
- if (!t || t.length === 0)
768
+ function St(t) {
769
+ const r = t.paths;
770
+ if (!r || r.length === 0)
730
771
  return Promise.resolve({
731
772
  totalSize: 0,
732
773
  maxFileDateModified: 0,
@@ -734,16 +775,16 @@ function gt(r) {
734
775
  countDirs: 0,
735
776
  countLinks: 0
736
777
  });
737
- 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;
738
- async function d(h) {
739
- if (!(i && await i(h)) && !jr(h))
740
- throw h;
778
+ 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;
779
+ async function d(m) {
780
+ if (!(i && await i(m)) && !Kr(m))
781
+ throw m;
741
782
  }
742
- function p(h) {
743
- return !(!l || l.minTotalContentSize != null && h < l.minTotalContentSize || l.maxNestedLevel != null && s > l.maxNestedLevel);
783
+ function p(m) {
784
+ return !(!l || l.minTotalContentSize != null && m < l.minTotalContentSize || l.maxNestedLevel != null && s > l.maxNestedLevel);
744
785
  }
745
- return Zt(async (h) => {
746
- const g = Xt(e, h), y = {
786
+ return rr(async (m) => {
787
+ const g = sr(e, m), y = {
747
788
  totalSize: 0,
748
789
  maxFileDateModified: 0,
749
790
  countFiles: 0,
@@ -769,8 +810,8 @@ function gt(r) {
769
810
  totalStat: y,
770
811
  abortSignal: g
771
812
  });
772
- } catch (E) {
773
- return await d(E), !1;
813
+ } catch (v) {
814
+ return await d(v), !1;
774
815
  }
775
816
  },
776
817
  count: 1,
@@ -778,33 +819,33 @@ function gt(r) {
778
819
  abortSignal: g
779
820
  }) : !0;
780
821
  }
781
- async function v($, T, x, S) {
822
+ async function E($, T, x, S) {
782
823
  S || (S = $);
783
- const E = await V({
824
+ const v = await V({
784
825
  pool: n,
785
826
  func: () => j.promises.lstat($).catch(d),
786
827
  count: 1,
787
828
  priority: X(T, X(1, a)),
788
829
  abortSignal: g
789
830
  });
790
- if (!E || !x && E.isFile())
831
+ if (!v || !x && v.isFile())
791
832
  return null;
792
- const B = zr($, E);
833
+ const B = Jr($, v);
793
834
  if (o.has(B))
794
835
  return null;
795
836
  o.add(B);
796
837
  let O = {
797
- totalSize: E.size,
798
- maxFileDateModified: E.isDirectory() ? 0 : E.mtimeMs,
838
+ totalSize: v.size,
839
+ maxFileDateModified: v.isDirectory() ? 0 : v.mtimeMs,
799
840
  countFiles: 0,
800
841
  countDirs: 0,
801
842
  countLinks: 0
802
843
  };
803
844
  const I = X(
804
845
  T,
805
- X(E.isDirectory() ? 2 : 3, a)
846
+ X(v.isDirectory() ? 2 : 3, a)
806
847
  );
807
- if (E.isSymbolicLink()) {
848
+ if (v.isSymbolicLink()) {
808
849
  if (c) {
809
850
  const C = await V({
810
851
  pool: n,
@@ -814,22 +855,22 @@ function gt(r) {
814
855
  abortSignal: g
815
856
  });
816
857
  if (C) {
817
- const N = k.isAbsolute(C) ? C : k.resolve(k.dirname(S), C), D = await v(
858
+ const N = k.isAbsolute(C) ? C : k.resolve(k.dirname(S), C), R = await E(
818
859
  N,
819
860
  T,
820
861
  x,
821
862
  S
822
863
  );
823
- D && (O = D);
864
+ R && (O = R);
824
865
  }
825
866
  }
826
867
  return (x || O.countFiles + O.countDirs + O.countLinks >= 1) && (O.countLinks += 1, await M(
827
868
  S,
828
- E,
869
+ v,
829
870
  O,
830
871
  I
831
- ) && (Re(y, O), w(S, O))), O;
832
- } else if (E.isDirectory()) {
872
+ ) && (Le(y, O), w(S, O))), O;
873
+ } else if (v.isDirectory()) {
833
874
  const C = await V({
834
875
  pool: n,
835
876
  func: () => j.promises.readdir($).catch(d),
@@ -838,10 +879,10 @@ function gt(r) {
838
879
  abortSignal: g
839
880
  });
840
881
  if (C) {
841
- for (let N = 0, D = C.length; N < D; N++)
882
+ for (let N = 0, R = C.length; N < R; N++)
842
883
  C[N] = k.join(S, C[N]);
843
- O = await gt({
844
- ...r,
884
+ O = await St({
885
+ ...t,
845
886
  paths: C,
846
887
  abortSignal: g,
847
888
  priority: I,
@@ -850,75 +891,75 @@ function gt(r) {
850
891
  });
851
892
  }
852
893
  }
853
- return (x || O.countFiles + O.countDirs + O.countLinks >= 1) && (E.isDirectory() ? O.countDirs += 1 : E.isFile() && (O.countFiles += 1), await M(
894
+ return (x || O.countFiles + O.countDirs + O.countLinks >= 1) && (v.isDirectory() ? O.countDirs += 1 : v.isFile() && (O.countFiles += 1), await M(
854
895
  S,
855
- E,
896
+ v,
856
897
  O,
857
898
  I
858
- ) && (Re(y, O), w(S, O))), O;
899
+ ) && (Le(y, O), w(S, O))), O;
859
900
  }
860
901
  const b = [];
861
- for (let $ = 0, T = t.length; $ < T; $++) {
862
- const x = Ur(t[$]), S = f ? f(x) : !0;
863
- S !== !1 && b.push(v(x, $, S));
902
+ for (let $ = 0, T = r.length; $ < T; $++) {
903
+ const x = Wr(r[$]), S = f ? f(x) : !0;
904
+ S !== !1 && b.push(E(x, $, S));
864
905
  }
865
906
  return await Promise.all(b), y;
866
907
  });
867
908
  }
868
- function wt(r) {
869
- return gt(r);
909
+ function xt(t) {
910
+ return St(t);
870
911
  }
871
- function qr(r, t) {
872
- if (!t || t === ".")
873
- return r;
874
- const s = r.startsWith("^");
875
- s && (r = r.substring(1));
876
- const o = r.startsWith("!");
877
- 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;
912
+ function Hr(t, r) {
913
+ if (!r || r === ".")
914
+ return t;
915
+ const s = t.startsWith("^");
916
+ s && (t = t.substring(1));
917
+ const o = t.startsWith("!");
918
+ 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;
878
919
  }
879
- function Gr(r) {
880
- const t = r.startsWith("!");
881
- return t && (r = r.substring(1)), r.startsWith("/") ? r = r.substring(1) : !r.startsWith("**") && !r.startsWith("../") && (r = `**/${r}`), t && (r = "!" + r), r;
920
+ function Qr(t) {
921
+ const r = t.startsWith("!");
922
+ return r && (t = t.substring(1)), t.startsWith("/") ? t = t.substring(1) : !t.startsWith("**") && !t.startsWith("../") && (t = `**/${t}`), r && (t = "!" + t), t;
882
923
  }
883
- function Fe(r) {
884
- return "^" + r;
924
+ function Pe(t) {
925
+ return "^" + t;
885
926
  }
886
- async function _r(r) {
887
- const s = (await j.promises.readFile(r, "utf-8")).split(`
927
+ async function Yr(t) {
928
+ const s = (await j.promises.readFile(t, "utf-8")).split(`
888
929
  `), o = [];
889
930
  return s.forEach((e) => {
890
931
  e = e.trim(), !(!e || e.startsWith("#")) && o.push(e);
891
932
  }), o;
892
933
  }
893
- async function yt(r) {
894
- const t = r.rootDir ?? ".", s = [];
895
- if (!r.globs?.length)
934
+ async function $t(t) {
935
+ const r = t.rootDir ?? ".", s = [];
936
+ if (!t.globs?.length)
896
937
  return s;
897
938
  const o = [];
898
- return r.globs.forEach((e) => {
899
- e.value && (e.valueType === "file-contains-patterns" ? o.push(e) : e.valueType === "pattern" && s.push(e.exclude ? Fe(e.value) : e.value));
939
+ return t.globs.forEach((e) => {
940
+ e.value && (e.valueType === "file-contains-patterns" ? o.push(e) : e.valueType === "pattern" && s.push(e.exclude ? Pe(e.value) : e.value));
900
941
  }), o.length && await Promise.all(
901
942
  o.map(async (e) => {
902
943
  await V({
903
944
  pool: Se,
904
945
  count: 1,
905
946
  func: async () => {
906
- const n = k.resolve(t, e.value), i = await _r(n), a = k.relative(t, k.dirname(n));
947
+ const n = k.resolve(r, e.value), i = await Yr(n), a = k.relative(r, k.dirname(n));
907
948
  i.forEach((c) => {
908
- c = Gr(c), c = qr(c, a), s.push(e.exclude ? Fe(c) : c);
949
+ c = Qr(c), c = Hr(c, a), s.push(e.exclude ? Pe(c) : c);
909
950
  });
910
951
  }
911
952
  });
912
953
  })
913
954
  ), s;
914
955
  }
915
- function bt({
916
- globs: r,
917
- rootDir: t,
956
+ function It({
957
+ globs: t,
958
+ rootDir: r,
918
959
  noCase: s
919
960
  }) {
920
961
  const o = [];
921
- return r.forEach((e) => {
962
+ return t.forEach((e) => {
922
963
  e = H(e).trim();
923
964
  const n = e.startsWith("^");
924
965
  n && (e = e.substring(1).trim());
@@ -928,12 +969,12 @@ function bt({
928
969
  `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.`
929
970
  );
930
971
  e.startsWith("/") && (e = "." + e);
931
- const a = H(t ? k.resolve(t, e) : e);
972
+ const a = H(r ? k.resolve(r, e) : e);
932
973
  if (!a)
933
974
  return;
934
975
  let c;
935
976
  try {
936
- c = rr(a, {
977
+ c = ir(a, {
937
978
  nocase: s ?? !1,
938
979
  dot: !0,
939
980
  strictBrackets: !0
@@ -960,61 +1001,61 @@ function bt({
960
1001
  return a ? !1 : i;
961
1002
  };
962
1003
  }
963
- async function Jr(r) {
964
- const t = r.rootDir ?? ".", s = [], o = {};
965
- r.result.countFiles && (o.countFiles = 0), r.result.size && (o.size = 0);
966
- const e = await yt({
967
- rootDir: t,
968
- globs: r.globs
1004
+ async function Vr(t) {
1005
+ const r = t.rootDir ?? ".", s = [], o = {};
1006
+ t.result.countFiles && (o.countFiles = 0), t.result.size && (o.size = 0);
1007
+ const e = await $t({
1008
+ rootDir: r,
1009
+ globs: t.globs
969
1010
  });
970
- return await wt({
971
- paths: [t],
1011
+ return await xt({
1012
+ paths: [r],
972
1013
  walkLinks: !0,
973
- matchPath: bt({
1014
+ matchPath: It({
974
1015
  globs: e,
975
- rootDir: t,
1016
+ rootDir: r,
976
1017
  noCase: !0
977
1018
  }),
978
1019
  handlePath: async ({ path: n, stat: i, itemStat: a }) => {
979
- const c = k.relative(t, n), l = i.isDirectory(), u = i.isFile();
1020
+ const c = k.relative(r, n), l = i.isDirectory(), u = i.isFile();
980
1021
  if (!l && !u)
981
1022
  return !0;
982
- 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 = {
1023
+ const f = H(c || "."), d = l ? "dir" : "file", p = l ? a.maxFileDateModified || null : i.mtimeMs, m = l ? a.totalSize : i.size, g = l ? a.countFiles : null, y = {
983
1024
  path: f,
984
1025
  type: d
985
1026
  };
986
- if (r.result.dateModified && (y.dateModified = p), r.result.size && (y.size = h), r.result.countFiles && (y.countFiles = g), r.dateModified && p != null) {
987
- const [w, M] = r.dateModified;
1027
+ if (t.result.dateModified && (y.dateModified = p), t.result.size && (y.size = m), t.result.countFiles && (y.countFiles = g), t.dateModified && p != null) {
1028
+ const [w, M] = t.dateModified;
988
1029
  if (w != null && p < w || M != null && p > M)
989
1030
  return !1;
990
1031
  }
991
- if (r.totalSize && h != null) {
992
- const [w, M] = r.totalSize;
993
- if (w != null && h < w || M != null && h > M)
1032
+ if (t.totalSize && m != null) {
1033
+ const [w, M] = t.totalSize;
1034
+ if (w != null && m < w || M != null && m > M)
994
1035
  return !1;
995
1036
  }
996
- 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;
1037
+ return d === "file" && (o.countFiles = (o.countFiles ?? 0) + 1), d === "file" && m != null && (o.size = (o.size ?? 0) + m), p != null && (o.dateModified == null || p > o.dateModified) && (o.dateModified = p), l && !t.result.dirs || u && !t.result.files || s.push(y), !0;
997
1038
  }
998
1039
  }), { items: s, totals: o };
999
1040
  }
1000
- const Be = ["B", "KB", "MB", "GB", "TB"], Le = 1024;
1001
- function Pe(r) {
1002
- if (r == null) return "-";
1003
- let t = r ?? 0, s = 0;
1004
- for (; t >= Le && s < Be.length - 1; )
1005
- t /= Le, s++;
1006
- return `${s === 0 ? t.toString() : t.toFixed(2)}${Be[s]}`;
1041
+ const Ae = ["B", "KB", "MB", "GB", "TB"], ze = 1024;
1042
+ function Ue(t) {
1043
+ if (t == null) return "-";
1044
+ let r = t ?? 0, s = 0;
1045
+ for (; r >= ze && s < Ae.length - 1; )
1046
+ r /= ze, s++;
1047
+ return `${s === 0 ? r.toString() : r.toFixed(2)}${Ae[s]}`;
1007
1048
  }
1008
- function Ae(r) {
1009
- const s = Date.now() - r;
1049
+ function je(t) {
1050
+ const s = Date.now() - t;
1010
1051
  if (s < 0) return "0s";
1011
1052
  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);
1012
1053
  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`;
1013
1054
  }
1014
- function Wr(r, t) {
1015
- return t?.length ? [...r].sort((s, o) => {
1016
- for (let e = 0, n = t.length; e < n; e++) {
1017
- const i = t[e];
1055
+ function Zr(t, r) {
1056
+ return r?.length ? [...t].sort((s, o) => {
1057
+ for (let e = 0, n = r.length; e < n; e++) {
1058
+ const i = r[e];
1018
1059
  let a, c;
1019
1060
  switch (i.field) {
1020
1061
  case "type":
@@ -1045,10 +1086,10 @@ function Wr(r, t) {
1045
1086
  return i.desc ? -l : l;
1046
1087
  }
1047
1088
  return 0;
1048
- }) : r;
1089
+ }) : t;
1049
1090
  }
1050
- function Kr(r, t) {
1051
- const s = Wr(r.items, t.sort ?? []), o = t.fields && t.fields.length > 0 ? t.fields : [];
1091
+ function Xr(t, r) {
1092
+ const s = Zr(t.items, r.sort ?? []), o = r.fields && r.fields.length > 0 ? r.fields : [];
1052
1093
  let e = "";
1053
1094
  if (s.length > 0 && o.length > 0) {
1054
1095
  for (let n = 0, i = o.length; n < i; n++) {
@@ -1079,10 +1120,10 @@ function Kr(r, t) {
1079
1120
  const u = o[c];
1080
1121
  switch (c > 0 && (e += " | "), u) {
1081
1122
  case "dateModified":
1082
- e += a.dateModified ? Ae(a.dateModified) : "-";
1123
+ e += a.dateModified ? je(a.dateModified) : "-";
1083
1124
  break;
1084
1125
  case "size":
1085
- e += Pe(a.size);
1126
+ e += Ue(a.size);
1086
1127
  break;
1087
1128
  case "type":
1088
1129
  e += a.type;
@@ -1101,24 +1142,24 @@ function Kr(r, t) {
1101
1142
  e.length > 0 && (e += `
1102
1143
  ---
1103
1144
  `);
1104
- const n = Pe(r.totals.size ?? 0), i = r.totals.dateModified ? `, last modified ${Ae(r.totals.dateModified)} ago` : "";
1105
- e += `Totals: ${r.totals.countFiles ?? 0} files in dirs, ${n}${i}`;
1145
+ const n = Ue(t.totals.size ?? 0), i = t.totals.dateModified ? `, last modified ${je(t.totals.dateModified)} ago` : "";
1146
+ e += `Totals: ${t.totals.countFiles ?? 0} files in dirs, ${n}${i}`;
1106
1147
  }
1107
1148
  return e;
1108
1149
  }
1109
- const Hr = "4.0.2", Qr = {
1110
- version: Hr
1111
- }, Ao = "Project Tools", zo = "project-tools", Uo = Qr.version, jo = "d00f70240703039df14c76176a055bce6b5484d2b552ba2c89820f03b8e5e60d", ze = 25e3;
1112
- function Ue(r) {
1113
- const t = r.match(
1150
+ const es = "4.0.2", ts = {
1151
+ version: es
1152
+ }, Go = "Project Tools", Jo = "project-tools", Wo = ts.version, Ko = "d00f70240703039df14c76176a055bce6b5484d2b552ba2c89820f03b8e5e60d", qe = 25e3;
1153
+ function _e(t) {
1154
+ const r = t.match(
1114
1155
  /^\s*(\d+(?:\.\d+)?)\s*([smhdwMY]|sec(onds?)?|min(utes?)?|hours?|days?|weeks?|months?|years?)\s*$/i
1115
1156
  );
1116
- if (!t)
1157
+ if (!r)
1117
1158
  throw new Error(
1118
- `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).`
1159
+ `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).`
1119
1160
  );
1120
- const s = parseFloat(t[1]);
1121
- let o = t[2];
1161
+ const s = parseFloat(r[1]);
1162
+ let o = r[2];
1122
1163
  switch (o !== "M" && (o = o.toLowerCase(), o.startsWith("month") ? o = "M" : o.length > 1 && (o = o[0])), o) {
1123
1164
  case "s":
1124
1165
  return s * 1e3;
@@ -1140,13 +1181,13 @@ function Ue(r) {
1140
1181
  );
1141
1182
  }
1142
1183
  }
1143
- function je(r) {
1144
- const t = r.match(/^\s*(\d+(?:\.\d+)?)\s*(B|KB|MB|GB|TB)\s*$/i);
1145
- if (!t)
1184
+ function Ge(t) {
1185
+ const r = t.match(/^\s*(\d+(?:\.\d+)?)\s*(B|KB|MB|GB|TB)\s*$/i);
1186
+ if (!r)
1146
1187
  throw new Error(
1147
- `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.`
1188
+ `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.`
1148
1189
  );
1149
- const s = parseFloat(t[1]), o = t[2].toUpperCase();
1190
+ const s = parseFloat(r[1]), o = r[2].toUpperCase();
1150
1191
  switch (o) {
1151
1192
  case "B":
1152
1193
  return s;
@@ -1164,49 +1205,49 @@ function je(r) {
1164
1205
  );
1165
1206
  }
1166
1207
  }
1167
- const St = m.object({
1168
- relativeRootDir: m.string().optional().describe(
1208
+ const Mt = h.object({
1209
+ relativeRootDir: h.string().optional().describe(
1169
1210
  'Relative path from project root to directory for listing. Use forward slashes. Leave empty for project root. Examples: "src", "src/components", "tests". Path must exist'
1170
1211
  ),
1171
- globs: m.array(m.string()).optional().describe(
1212
+ globs: h.array(h.string()).optional().describe(
1172
1213
  'Glob patterns to filter which files/directories to include. Add leading ** to match files and dirs in subdirectories. Examples: ["**/*.js"] (JavaScript files), ["src/**/*.ts"] (TypeScript files in src), ["**/dir/"] (all directories named "dir"), ["!node_modules"] (exclude {rootDir}/node_modules). If omitted, includes all files matching other criteria. Supports standard glob syntax: * (any chars), ** (any dirs), ? (single char), [abc] (char class)'
1173
1214
  ),
1174
- showFiles: m.boolean().optional().describe(
1215
+ showFiles: h.boolean().optional().describe(
1175
1216
  "Whether to show regular files in the report table. Set to true to show files, false to hide them from the table. When both showFiles and showDirs are false, nothing will be shown in the table. It Does not affect totals. Default is false (do not show files in the table)"
1176
1217
  ),
1177
- showDirs: m.boolean().optional().describe(
1218
+ showDirs: h.boolean().optional().describe(
1178
1219
  "Whether to show directories in the report table. Set to true to show directories, false to hide them from the table. When both showFiles and showDirs are false, nothing will be shown in the table. It Does not affect totals. Default is true (show directories in the table)"
1179
1220
  ),
1180
- sortBy: m.array(
1181
- m.object({
1182
- field: m.enum(["type", "path", "lastModified", "size", "totalCountFiles"]).describe(
1221
+ sortBy: h.array(
1222
+ h.object({
1223
+ field: h.enum(["type", "path", "lastModified", "size", "totalCountFiles"]).describe(
1183
1224
  'Field to sort results by. "type" sorts files before directories. "path" sorts alphabetically by file/directory name. "lastModified" sorts by modification time (newest first when desc=true). "size" sorts by file/directory size (largest first when desc=true). "totalCountFiles" sorts by total files count (highest first when desc=true, directories only)'
1184
1225
  ),
1185
- desc: m.boolean().optional().describe("Sort in descending order (largest/newest first)")
1226
+ desc: h.boolean().optional().describe("Sort in descending order (largest/newest first)")
1186
1227
  })
1187
1228
  ).optional().describe(
1188
1229
  'Multi-level sorting configuration. Sorts are applied in array order - first sort is primary, second is secondary, etc. Example: [{field: "type", desc: false}, {field: "size", desc: true}] sorts by type ascending, then by size descending within each type'
1189
1230
  ),
1190
- fields: m.array(m.enum(["type", "path", "lastModified", "size", "totalCountFiles"])).optional().describe(
1231
+ fields: h.array(h.enum(["type", "path", "lastModified", "size", "totalCountFiles"])).optional().describe(
1191
1232
  'Which data fields to include in the formatted table output. "type" shows file/directory indicator. "path" shows relative file/directory path. "lastModified" shows last modification time as time-ago format (5m, 2h, 3d, etc). "size" shows file/directory size in human-readable format (KB, MB, GB). "totalCountFiles" shows total files count for directories (displays "-" for files). Adding lastModified, size, or totalCountFiles fields increases processing time. Do not set fields if you want to show only totals summary'
1192
1233
  ),
1193
- minTimeAgo: m.string().optional().describe(
1234
+ minTimeAgo: h.string().optional().describe(
1194
1235
  'Filter files/directories modified at least this long ago. Only items older than this duration will be included. Format: number + unit (s/m/h/d/w/M/Y). Examples: "1h" (modified more than 1 hour ago), "7d" (modified more than 7 days ago), "6M" (modified more than 6 months ago)'
1195
1236
  ),
1196
- maxTimeAgo: m.string().optional().describe(
1237
+ maxTimeAgo: h.string().optional().describe(
1197
1238
  'Filter files/directories modified at most this long ago. Only items newer than this duration will be included. Format: number + unit (s/m/h/d/w/M/Y). Examples: "1h" (modified within last hour), "7d" (modified within last 7 days), "1M" (modified within last month). Combine with minTimeAgo for date ranges'
1198
1239
  ),
1199
- minTotalSize: m.string().optional().describe(
1240
+ minTotalSize: h.string().optional().describe(
1200
1241
  'Filter files/directories with total size at least 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: "1KB" (at least 1 kilobyte), "100MB" (at least 100 megabytes), "1.5GB" (at least 1.5 gigabytes)'
1201
1242
  ),
1202
- maxTotalSize: m.string().optional().describe(
1243
+ maxTotalSize: h.string().optional().describe(
1203
1244
  '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'
1204
1245
  )
1205
1246
  });
1206
- async function Yr(r, t) {
1247
+ async function rs(t, r) {
1207
1248
  let s;
1208
1249
  try {
1209
- s = St.parse(r);
1250
+ s = Mt.parse(t);
1210
1251
  } catch (y) {
1211
1252
  return {
1212
1253
  error: F(y)
@@ -1236,16 +1277,13 @@ async function Yr(r, t) {
1236
1277
  };
1237
1278
  }) ?? null;
1238
1279
  (!d || d.length === 0) && (d = [{ field: "path", desc: !1 }]);
1239
- const p = d?.map((y) => y.field) || [];
1240
- if (!t.workingDir)
1241
- return { error: "Working directory is not configured" };
1242
- const h = be(
1243
- t.workingDir,
1280
+ const p = d?.map((y) => y.field) || [], m = be(
1281
+ r.workingDir,
1244
1282
  s.relativeRootDir
1245
1283
  );
1246
- if ("error" in h)
1247
- return { error: h.error };
1248
- const g = h.path;
1284
+ if ("error" in m)
1285
+ return { error: m.error };
1286
+ const g = m.path;
1249
1287
  try {
1250
1288
  try {
1251
1289
  await j.promises.access(g, j.constants.F_OK);
@@ -1260,7 +1298,7 @@ async function Yr(r, t) {
1260
1298
  value: S,
1261
1299
  valueType: "pattern",
1262
1300
  exclude: !1
1263
- })) : [{ value: "**", valueType: "pattern", exclude: !1 }], w = t.globsExclude || [], M = [...y, ...w], v = {
1301
+ })) : [{ value: "**", valueType: "pattern", exclude: !1 }], w = r.globsExclude || [], M = [...y, ...w], E = {
1264
1302
  files: e ?? !1,
1265
1303
  dirs: n ?? !1,
1266
1304
  dateModified: f.includes("dateModified") || p.includes("dateModified"),
@@ -1270,8 +1308,8 @@ async function Yr(r, t) {
1270
1308
  let b = null, $ = null;
1271
1309
  if (a || c)
1272
1310
  try {
1273
- const S = Date.now(), E = c ? S - Ue(c) : null, B = a ? S - Ue(a) : null;
1274
- b = [E, B];
1311
+ const S = Date.now(), v = c ? S - _e(c) : null, B = a ? S - _e(a) : null;
1312
+ b = [v, B];
1275
1313
  } catch (S) {
1276
1314
  return {
1277
1315
  error: S instanceof Error ? S.message : "Unknown error parsing time ago filter"
@@ -1279,24 +1317,24 @@ async function Yr(r, t) {
1279
1317
  }
1280
1318
  if (l || u)
1281
1319
  try {
1282
- const S = l ? je(l) : null, E = u ? je(u) : null;
1283
- $ = [S, E];
1320
+ const S = l ? Ge(l) : null, v = u ? Ge(u) : null;
1321
+ $ = [S, v];
1284
1322
  } catch (S) {
1285
1323
  return {
1286
1324
  error: S instanceof Error ? S.message : "Unknown error parsing size filter"
1287
1325
  };
1288
1326
  }
1289
- const T = await Jr({
1327
+ const T = await Vr({
1290
1328
  rootDir: g || null,
1291
1329
  globs: M,
1292
- result: v,
1330
+ result: E,
1293
1331
  dateModified: b,
1294
1332
  totalSize: $
1295
1333
  });
1296
- return T.items.length > ze ? {
1297
- error: `Number of paths (${T.items.length}) exceeds maximum allowed (${ze}). Consider using more specific glob patterns or filters to reduce the result set.`
1334
+ return T.items.length > qe ? {
1335
+ error: `Number of paths (${T.items.length}) exceeds maximum allowed (${qe}). Consider using more specific glob patterns or filters to reduce the result set.`
1298
1336
  } : {
1299
- output: Kr(T, {
1337
+ output: Xr(T, {
1300
1338
  sort: d,
1301
1339
  fields: f,
1302
1340
  totals: !0
@@ -1306,16 +1344,16 @@ async function Yr(r, t) {
1306
1344
  return { error: y instanceof Error ? y.message : "Unknown error" };
1307
1345
  }
1308
1346
  }
1309
- function Vr(r, t) {
1310
- r(
1347
+ function ss(t, r) {
1348
+ t(
1311
1349
  "fs-list",
1312
1350
  {
1313
1351
  title: "List Files and Directories",
1314
1352
  description: "List files and directories with advanced filtering, sorting and formatting options. Use this to analyze filesystem structure",
1315
- inputSchema: St.shape
1353
+ inputSchema: Mt.shape
1316
1354
  },
1317
1355
  async (s) => {
1318
- const o = await Yr(s, t);
1356
+ const o = await rs(s, r);
1319
1357
  return o.error ? `Method: fs-list(${JSON.stringify(s)})
1320
1358
  ❌ Error: ${o.error}` : `Method: fs-list(${JSON.stringify(s)})
1321
1359
  ${o.output || JSON.stringify(o, null, 2)}`;
@@ -1323,27 +1361,27 @@ ${o.output || JSON.stringify(o, null, 2)}`;
1323
1361
  );
1324
1362
  }
1325
1363
  const ue = /* @__PURE__ */ new Map();
1326
- let Zr = 0;
1327
- function Xr() {
1328
- return `${++Zr}-${Math.random().toString(36).slice(2)}`;
1364
+ let os = 0;
1365
+ function ns() {
1366
+ return `${++os}-${Math.random().toString(36).slice(2)}`;
1329
1367
  }
1330
- function Z(r) {
1331
- return ue.has(r) || ue.set(r, {
1368
+ function Z(t) {
1369
+ return ue.has(t) || ue.set(t, {
1332
1370
  fsSnapshotQueries: /* @__PURE__ */ new Map(),
1333
1371
  fsSnapshots: /* @__PURE__ */ new Map(),
1334
1372
  preparedReplace: null
1335
- }), ue.get(r);
1373
+ }), ue.get(t);
1336
1374
  }
1337
- function qe(r) {
1338
- const t = r.match(
1375
+ function Je(t) {
1376
+ const r = t.match(
1339
1377
  /^\s*(\d+(?:\.\d+)?)\s*([smhdwMY]|sec(onds?)?|min(utes?)?|hours?|days?|weeks?|months?|years?)\s*$/i
1340
1378
  );
1341
- if (!t)
1379
+ if (!r)
1342
1380
  throw new Error(
1343
- `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).`
1381
+ `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).`
1344
1382
  );
1345
- const s = parseFloat(t[1]);
1346
- let o = t[2];
1383
+ const s = parseFloat(r[1]);
1384
+ let o = r[2];
1347
1385
  switch (o !== "M" && (o = o.toLowerCase(), o.startsWith("month") ? o = "M" : o.length > 1 && (o = o[0])), o) {
1348
1386
  case "s":
1349
1387
  return s * 1e3;
@@ -1365,13 +1403,13 @@ function qe(r) {
1365
1403
  );
1366
1404
  }
1367
1405
  }
1368
- function Ge(r) {
1369
- const t = r.match(/^\s*(\d+(?:\.\d+)?)\s*(B|KB|MB|GB|TB)\s*$/i);
1370
- if (!t)
1406
+ function We(t) {
1407
+ const r = t.match(/^\s*(\d+(?:\.\d+)?)\s*(B|KB|MB|GB|TB)\s*$/i);
1408
+ if (!r)
1371
1409
  throw new Error(
1372
- `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.`
1410
+ `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.`
1373
1411
  );
1374
- const s = parseFloat(t[1]), o = t[2].toUpperCase();
1412
+ const s = parseFloat(r[1]), o = r[2].toUpperCase();
1375
1413
  switch (o) {
1376
1414
  case "B":
1377
1415
  return s;
@@ -1389,54 +1427,54 @@ function Ge(r) {
1389
1427
  );
1390
1428
  }
1391
1429
  }
1392
- const xe = m.object({
1393
- name: m.string().describe(
1430
+ const xe = h.object({
1431
+ name: h.string().describe(
1394
1432
  "Unique name for the filesystem snapshot query. Recommended format: kebab-case-1, kebab-case-2, ..."
1395
1433
  ),
1396
- relativeRootDir: m.string().optional().describe(
1434
+ relativeRootDir: h.string().optional().describe(
1397
1435
  'Relative path from project root to directory for snapshot. Use forward slashes. Leave empty for project root. Examples: "src", "src/components", "tests". Path must exist'
1398
1436
  ),
1399
- bulkGlobs: m.array(m.string()).optional().describe(
1437
+ bulkGlobs: h.array(h.string()).optional().describe(
1400
1438
  'Glob patterns to filter files/directories. Include all patterns in this single array; never split across multiple tool calls. Add leading ** for recursive matching. Examples: ["**/*.js"], ["src/**/*.ts"], ["**/*.{ts,svelte}"], ["!node_modules"]. If omitted, includes all files matching other criteria. Supports: * (any chars), ** (any dirs), ? (single char), [abc] (char class)'
1401
1439
  ),
1402
- types: m.array(m.enum(["file", "dir"])).optional().describe(
1440
+ types: h.array(h.enum(["file", "dir"])).optional().describe(
1403
1441
  "Types of items to include in the snapshot. If omitted, includes both files and directories"
1404
1442
  ),
1405
- extraFields: m.array(m.enum(["lastModified", "size", "countMatched"])).optional().describe(
1443
+ extraFields: h.array(h.enum(["lastModified", "size", "countMatched"])).optional().describe(
1406
1444
  'Which extra data fields to include in the snapshot tree output. "lastModified" shows last modification time as time-ago format (5m, 2h, 3d, etc). "size" shows file/directory size in human-readable format (KB, MB, GB). "countMatched" shows total matched items count'
1407
1445
  ),
1408
- minTimeAgo: m.string().optional().describe(
1446
+ minTimeAgo: h.string().optional().describe(
1409
1447
  'Filter files/directories modified at least this long ago. Only items older than this duration will be included. Format: number + unit (s/m/h/d/w/M/Y). Examples: "1h" (modified more than 1 hour ago), "7d" (modified more than 7 days ago), "6M" (modified more than 6 months ago)'
1410
1448
  ),
1411
- maxTimeAgo: m.string().optional().describe(
1449
+ maxTimeAgo: h.string().optional().describe(
1412
1450
  'Filter files/directories modified at most this long ago. Only items newer than this duration will be included. Format: number + unit (s/m/h/d/w/M/Y). Examples: "1h" (modified within last hour), "7d" (modified within last 7 days), "1M" (modified within last month). Combine with minTimeAgo for date ranges'
1413
1451
  ),
1414
- minTotalSize: m.string().optional().describe(
1452
+ minTotalSize: h.string().optional().describe(
1415
1453
  'Filter files/directories with total size at least 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: "1KB" (at least 1 kilobyte), "100MB" (at least 100 megabytes), "1.5GB" (at least 1.5 gigabytes)'
1416
1454
  ),
1417
- maxTotalSize: m.string().optional().describe(
1455
+ maxTotalSize: h.string().optional().describe(
1418
1456
  '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'
1419
1457
  )
1420
- }), _e = new Map(
1458
+ }), Ke = new Map(
1421
1459
  [
1422
1460
  "name",
1423
1461
  "type",
1424
1462
  "countMatched",
1425
1463
  "size",
1426
1464
  "dateModified"
1427
- ].map((r, t) => [r, t])
1465
+ ].map((t, r) => [t, r])
1428
1466
  );
1429
- function es(r, t) {
1430
- const s = _e.get(r) ?? 1 / 0, o = _e.get(t) ?? 1 / 0;
1467
+ function is(t, r) {
1468
+ const s = Ke.get(t) ?? 1 / 0, o = Ke.get(r) ?? 1 / 0;
1431
1469
  return s > o ? 1 : s < o ? -1 : 0;
1432
1470
  }
1433
- async function xt(r, t, s) {
1471
+ async function Tt(t, r, s) {
1434
1472
  let o;
1435
1473
  try {
1436
- o = xe.parse(r);
1437
- } catch (h) {
1474
+ o = xe.parse(t);
1475
+ } catch (m) {
1438
1476
  return {
1439
- error: F(h)
1477
+ error: F(m)
1440
1478
  };
1441
1479
  }
1442
1480
  const {
@@ -1452,11 +1490,8 @@ async function xt(r, t, s) {
1452
1490
  return {
1453
1491
  error: "Session ID is required"
1454
1492
  };
1455
- const f = Z(s.sessionId);
1456
- if (!t.workingDir)
1457
- return { error: "Working directory is not configured" };
1458
- const d = be(
1459
- t.workingDir,
1493
+ const f = Z(s.sessionId), d = be(
1494
+ r.workingDir,
1460
1495
  o.relativeRootDir
1461
1496
  );
1462
1497
  if ("error" in d)
@@ -1472,18 +1507,18 @@ async function xt(r, t, s) {
1472
1507
  };
1473
1508
  throw x;
1474
1509
  }
1475
- const h = o.extraFields ? o.extraFields.map((x) => x === "lastModified" ? "dateModified" : x) : [];
1476
- h.includes("name") || h.push("name"), h.sort(es);
1510
+ const m = o.extraFields ? o.extraFields.map((x) => x === "lastModified" ? "dateModified" : x) : [];
1511
+ m.includes("name") || m.push("name"), m.sort(is);
1477
1512
  const g = n && n.length > 0 ? n.map((x) => ({
1478
1513
  value: x,
1479
1514
  valueType: "pattern",
1480
1515
  exclude: !1
1481
- })) : [{ value: "**", valueType: "pattern", exclude: !1 }], y = t.globsExclude || [], w = [...g, ...y];
1482
- let M = null, v = null;
1516
+ })) : [{ value: "**", valueType: "pattern", exclude: !1 }], y = r.globsExclude || [], w = [...g, ...y];
1517
+ let M = null, E = null;
1483
1518
  if (a || c)
1484
1519
  try {
1485
- const x = Date.now(), S = c ? x - qe(c) : null, E = a ? x - qe(a) : null;
1486
- M = [S, E];
1520
+ const x = Date.now(), S = c ? x - Je(c) : null, v = a ? x - Je(a) : null;
1521
+ M = [S, v];
1487
1522
  } catch (x) {
1488
1523
  return {
1489
1524
  error: x instanceof Error ? x.message : "Unknown error parsing time ago filter"
@@ -1491,8 +1526,8 @@ async function xt(r, t, s) {
1491
1526
  }
1492
1527
  if (l || u)
1493
1528
  try {
1494
- const x = l ? Ge(l) : null, S = u ? Ge(u) : null;
1495
- v = [x, S];
1529
+ const x = l ? We(l) : null, S = u ? We(u) : null;
1530
+ E = [x, S];
1496
1531
  } catch (x) {
1497
1532
  return {
1498
1533
  error: x instanceof Error ? x.message : "Unknown error parsing size filter"
@@ -1505,20 +1540,20 @@ async function xt(r, t, s) {
1505
1540
  matchFiles: b,
1506
1541
  matchDirs: $,
1507
1542
  dateModified: M,
1508
- totalSize: v,
1509
- fields: h
1543
+ totalSize: E,
1544
+ fields: m
1510
1545
  };
1511
1546
  return f.fsSnapshotQueries.set(e, T), {
1512
1547
  snapshotQuery: T
1513
1548
  };
1514
- } catch (h) {
1549
+ } catch (m) {
1515
1550
  return {
1516
- error: h instanceof Error ? h.message : "Unknown error"
1551
+ error: m instanceof Error ? m.message : "Unknown error"
1517
1552
  };
1518
1553
  }
1519
1554
  }
1520
- function ts(r, t) {
1521
- r(
1555
+ function as(t, r) {
1556
+ t(
1522
1557
  "fs-snapshot-query-create",
1523
1558
  {
1524
1559
  title: "Create Filesystem Snapshot Query",
@@ -1526,21 +1561,21 @@ function ts(r, t) {
1526
1561
  inputSchema: xe.shape
1527
1562
  },
1528
1563
  async (s, o) => {
1529
- const e = await xt(s, t, o);
1564
+ const e = await Tt(s, r, o);
1530
1565
  return e.error != null ? `Method: fs-snapshot-query-create(${JSON.stringify(s)})
1531
1566
  ❌ Error: ${e.error}` : `Method: fs-snapshot-query-create(${JSON.stringify(s)})
1532
1567
  ✅ Filesystem snapshot query "${e.snapshotQuery.name}" created successfully`;
1533
1568
  }
1534
1569
  );
1535
1570
  }
1536
- function le(r) {
1537
- const { idToNode: t, idToChildIds: s } = r, o = t.get(null);
1571
+ function le(t) {
1572
+ const { idToNode: r, idToChildIds: s } = t, o = r.get(null);
1538
1573
  if (o == null)
1539
1574
  throw new Error(
1540
1575
  "Impossible behavior: root node (id: null) not found in idToNode"
1541
1576
  );
1542
1577
  const e = /* @__PURE__ */ new Map();
1543
- return t.forEach((n, i) => {
1578
+ return r.forEach((n, i) => {
1544
1579
  if (n != null) {
1545
1580
  if (e.has(n)) {
1546
1581
  const a = e.get(n);
@@ -1552,18 +1587,18 @@ function le(r) {
1552
1587
  }
1553
1588
  }), {
1554
1589
  root: o,
1555
- getNode: (n) => t.get(n) ?? null,
1590
+ getNode: (n) => r.get(n) ?? null,
1556
1591
  getId: (n) => e.get(n) ?? null,
1557
1592
  getChilds: (n) => {
1558
1593
  let i = e.get(n);
1559
1594
  if (i == null)
1560
- if (n === t.get(null))
1595
+ if (n === r.get(null))
1561
1596
  i = null;
1562
1597
  else
1563
1598
  throw new Error("Impossible behavior: node not found in idToNode");
1564
1599
  const a = s.get(i);
1565
1600
  return a == null ? null : a.map((c) => {
1566
- const l = t.get(c);
1601
+ const l = r.get(c);
1567
1602
  if (l == null)
1568
1603
  throw new Error(
1569
1604
  `Child node with id '${c}' not found in idToNode`
@@ -1573,22 +1608,22 @@ function le(r) {
1573
1608
  }
1574
1609
  };
1575
1610
  }
1576
- function $t(r, t, s) {
1611
+ function Ct(t, r, s) {
1577
1612
  let o = null;
1578
- for (let e = 0, n = t.length; e < n; e++) {
1579
- const i = t[e], a = r(i), c = a == null ? null : $t(r, a, s), l = s(i, c);
1613
+ for (let e = 0, n = r.length; e < n; e++) {
1614
+ const i = r[e], a = t(i), c = a == null ? null : Ct(t, a, s), l = s(i, c);
1580
1615
  l != null && (o == null && (o = []), o.push(l));
1581
1616
  }
1582
1617
  return o;
1583
1618
  }
1584
- function It(r) {
1585
- const { getId: t, getChilds: s, rootNodes: o, createSnapshotNode: e } = r, n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), c = $t(
1619
+ function vt(t) {
1620
+ const { getId: r, getChilds: s, rootNodes: o, createSnapshotNode: e } = t, n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), c = Ct(
1586
1621
  s,
1587
1622
  o,
1588
1623
  (u, f) => {
1589
1624
  const d = e(u, f);
1590
1625
  if (u != null && d != null) {
1591
- const p = t(u);
1626
+ const p = r(u);
1592
1627
  n.set(p, d), i.set(d, p);
1593
1628
  }
1594
1629
  return d != null && f != null && a.set(
@@ -1607,11 +1642,11 @@ function It(r) {
1607
1642
  idToChildIds: a
1608
1643
  };
1609
1644
  }
1610
- function me(r) {
1611
- return r = r != null ? H(r).replace(/\/$/, "") : null, !r || r === "." ? null : r;
1645
+ function me(t) {
1646
+ return t = t != null ? H(t).replace(/\/$/, "") : null, !t || t === "." ? null : t;
1612
1647
  }
1613
- async function rs(r) {
1614
- const t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), o = k.resolve(r.rootDir || "."), n = {
1648
+ async function ls(t) {
1649
+ const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), o = k.resolve(t.rootDir || "."), n = {
1615
1650
  path: ".",
1616
1651
  name: k.basename(o),
1617
1652
  type: "dir",
@@ -1619,15 +1654,15 @@ async function rs(r) {
1619
1654
  dateModified: null,
1620
1655
  size: 0
1621
1656
  };
1622
- t.set(null, n);
1623
- const i = await yt({
1657
+ r.set(null, n);
1658
+ const i = await $t({
1624
1659
  rootDir: o,
1625
- globs: r.globs
1660
+ globs: t.globs
1626
1661
  });
1627
- return await wt({
1662
+ return await xt({
1628
1663
  paths: [o],
1629
1664
  walkLinks: !0,
1630
- matchPath: bt({
1665
+ matchPath: It({
1631
1666
  globs: i,
1632
1667
  rootDir: o,
1633
1668
  noCase: !0
@@ -1636,14 +1671,14 @@ async function rs(r) {
1636
1671
  const u = k.relative(o, a), f = c.isDirectory(), d = c.isFile();
1637
1672
  if (!f && !d)
1638
1673
  return !0;
1639
- const p = me(u || "."), h = f ? "dir" : "file", g = f ? null : c.mtimeMs, y = c.size;
1674
+ const p = me(u || "."), m = f ? "dir" : "file", g = f ? null : c.mtimeMs, y = c.size;
1640
1675
  let w = !0;
1641
- if (d && !r.matchFiles && (w = !1), f && !r.matchDirs && (w = !1), w && d && r.dateModified && g != null) {
1642
- const [$, T] = r.dateModified;
1676
+ if (d && !t.matchFiles && (w = !1), f && !t.matchDirs && (w = !1), w && d && t.dateModified && g != null) {
1677
+ const [$, T] = t.dateModified;
1643
1678
  ($ != null && g < $ || T != null && g > T) && (w = !1);
1644
1679
  }
1645
- if (w && d && r.totalSize && y != null) {
1646
- const [$, T] = r.totalSize;
1680
+ if (w && d && t.totalSize && y != null) {
1681
+ const [$, T] = t.totalSize;
1647
1682
  ($ != null && y < $ || T != null && y > T) && (w = !1);
1648
1683
  }
1649
1684
  if (f && !w) {
@@ -1653,33 +1688,33 @@ async function rs(r) {
1653
1688
  const M = {
1654
1689
  path: p ?? ".",
1655
1690
  name: k.basename(a),
1656
- type: h,
1691
+ type: m,
1657
1692
  dateModified: g,
1658
1693
  size: y,
1659
1694
  isMatched: w
1660
1695
  };
1661
1696
  if (p == null)
1662
1697
  return n.dateModified = g, n.size = y, n.isMatched = w, !0;
1663
- t.set(p, M);
1664
- const v = me(H(k.dirname(p)));
1665
- let b = s.get(v);
1666
- return b || (b = [], s.set(v, b)), b.push(p), !0;
1698
+ r.set(p, M);
1699
+ const E = me(H(k.dirname(p)));
1700
+ let b = s.get(E);
1701
+ return b || (b = [], s.set(E, b)), b.push(p), !0;
1667
1702
  }
1668
1703
  }), {
1669
- idToNode: t,
1704
+ idToNode: r,
1670
1705
  idToChildIds: s
1671
1706
  };
1672
1707
  }
1673
- const ss = [
1674
- { name: "[ ]", match: (r) => r === 32, min: 2, max: 81 },
1675
- { name: "[\\t]", match: (r) => r === 9, min: 2, max: 20 },
1676
- { name: "[\\n]", match: (r) => r === 10, min: 2, max: 14 },
1677
- { name: "[-]", match: (r) => r === 45, min: 2, max: 16 },
1678
- { name: "[=]", match: (r) => r === 61, min: 2, max: 16 },
1679
- { name: "[_]", match: (r) => r === 95, min: 2, max: 16 },
1680
- { name: "[*]", match: (r) => r === 42, min: 2, max: 16 },
1681
- { name: "[.]", match: (r) => r === 46, min: 2, max: 16 },
1682
- { name: "[0-9]", match: (r) => r >= 48 && r <= 57, min: 2, max: 3 }
1708
+ const cs = [
1709
+ { name: "[ ]", match: (t) => t === 32, min: 2, max: 81 },
1710
+ { name: "[\\t]", match: (t) => t === 9, min: 2, max: 20 },
1711
+ { name: "[\\n]", match: (t) => t === 10, min: 2, max: 14 },
1712
+ { name: "[-]", match: (t) => t === 45, min: 2, max: 16 },
1713
+ { name: "[=]", match: (t) => t === 61, min: 2, max: 16 },
1714
+ { name: "[_]", match: (t) => t === 95, min: 2, max: 16 },
1715
+ { name: "[*]", match: (t) => t === 42, min: 2, max: 16 },
1716
+ { name: "[.]", match: (t) => t === 46, min: 2, max: 16 },
1717
+ { name: "[0-9]", match: (t) => t >= 48 && t <= 57, min: 2, max: 3 }
1683
1718
  // { name: '[a-z]', match: c => c >= 97 && c <= 122, min: 2, max: 2 },
1684
1719
  // { name: '[A-Z]', match: c => c >= 65 && c <= 90, min: 2, max: 2 },
1685
1720
  // Other ASCII symbols
@@ -1693,21 +1728,21 @@ const ss = [
1693
1728
  // max: 2,
1694
1729
  // },
1695
1730
  ];
1696
- function Je(r, t = ss) {
1697
- const s = r.length;
1731
+ function He(t, r = cs) {
1732
+ const s = t.length;
1698
1733
  if (s === 0) return 0;
1699
- const o = t.length;
1734
+ const o = r.length;
1700
1735
  if (o === 0)
1701
1736
  return s;
1702
1737
  let e = 0, n = 0;
1703
1738
  for (; n < s; ) {
1704
- const i = r.charCodeAt(n);
1739
+ const i = t.charCodeAt(n);
1705
1740
  let a = !1;
1706
1741
  for (let c = 0; c < o; c++) {
1707
- const l = t[c];
1742
+ const l = r[c];
1708
1743
  if (l.match(i)) {
1709
1744
  let u = 1;
1710
- for (; ++n < s && l.match(r.charCodeAt(n)) && u < l.max; )
1745
+ for (; ++n < s && l.match(t.charCodeAt(n)) && u < l.max; )
1711
1746
  u++;
1712
1747
  if (u >= l.min) {
1713
1748
  e++, a = !0;
@@ -1719,27 +1754,27 @@ function Je(r, t = ss) {
1719
1754
  }
1720
1755
  return e;
1721
1756
  }
1722
- function Mt(r) {
1723
- let t = 0;
1724
- return t += Je(r.textOpen) + 1, r.textClose != null && (t += Je(r.textClose) + 1), r.indent && (t += 1), t;
1757
+ function Et(t) {
1758
+ let r = 0;
1759
+ return r += He(t.textOpen) + 1, t.textClose != null && (r += He(t.textClose) + 1), t.indent && (r += 1), r;
1725
1760
  }
1726
- const We = ["B", "KB", "MB", "GB", "TB"], Ke = 1024;
1727
- function os(r) {
1728
- if (r == null) return "-";
1729
- let t = r ?? 0, s = 0;
1730
- for (; t >= Ke && s < We.length - 1; )
1731
- t /= Ke, s++;
1732
- return `${s === 0 ? t.toString() : t.toFixed(2)}${We[s]}`;
1761
+ const Qe = ["B", "KB", "MB", "GB", "TB"], Ye = 1024;
1762
+ function us(t) {
1763
+ if (t == null) return "-";
1764
+ let r = t ?? 0, s = 0;
1765
+ for (; r >= Ye && s < Qe.length - 1; )
1766
+ r /= Ye, s++;
1767
+ return `${s === 0 ? r.toString() : r.toFixed(2)}${Qe[s]}`;
1733
1768
  }
1734
- function ns(r) {
1735
- const s = Date.now() - r;
1769
+ function ds(t) {
1770
+ const s = Date.now() - t;
1736
1771
  if (s < 0) return "0s";
1737
1772
  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);
1738
1773
  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`;
1739
1774
  }
1740
- function is(r) {
1775
+ function fs(t) {
1741
1776
  return function(s, o) {
1742
- const e = r.get(s), n = r.get(o);
1777
+ const e = t.get(s), n = t.get(o);
1743
1778
  if (e.type !== n.type)
1744
1779
  return e.type === "file" ? -1 : 1;
1745
1780
  if (e.type === "file")
@@ -1750,26 +1785,26 @@ function is(r) {
1750
1785
  }
1751
1786
  };
1752
1787
  }
1753
- function as(r) {
1754
- const t = r.fields ?? [];
1788
+ function ps(t) {
1789
+ const r = t.fields ?? [];
1755
1790
  return function(o, e) {
1756
1791
  let n = "", i, a = 0;
1757
1792
  const c = e ? e.length : 0;
1758
- let l = 1, u, f = 0, d = 0, p = 0, h = 0, g = null, y, w, M;
1793
+ let l = 1, u, f = 0, d = 0, p = 0, m = 0, g = null, y, w, M;
1759
1794
  if (e)
1760
1795
  for (let b = 0; b < e.length; b++) {
1761
1796
  const $ = e[b];
1762
- a += $.countMatched, l += $.countTotal, f += $.tokens, d += $.tokensTotal, p += $.size, h += $.countFiles, $.dateModified != null && (g == null || $.dateModified > g) && (g = $.dateModified);
1797
+ a += $.countMatched, l += $.countTotal, f += $.tokens, d += $.tokensTotal, p += $.size, m += $.countFiles, $.dateModified != null && (g == null || $.dateModified > g) && (g = $.dateModified);
1763
1798
  }
1764
- 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);
1765
- for (let b = 0, $ = t.length; b < $; b++) {
1766
- const T = t[b];
1799
+ o ? (y = o.type, w = o.name, M = o.path, i = o.isMatched, i && (a += 1), o.type === "file" ? (p = o.size || 0, m = 1, g = o.dateModified || null) : o.dateModified != null && (g == null || o.dateModified > g) && (g = o.dateModified)) : (y = "dir", w = "<root>", M = ".", i = !0);
1800
+ for (let b = 0, $ = r.length; b < $; b++) {
1801
+ const T = r[b];
1767
1802
  switch (b > 0 && (n += " "), T) {
1768
1803
  case "dateModified":
1769
- n += g ? ns(g) : "-";
1804
+ n += g ? ds(g) : "-";
1770
1805
  break;
1771
1806
  case "size":
1772
- n += os(p);
1807
+ n += us(p);
1773
1808
  break;
1774
1809
  case "type":
1775
1810
  n += y;
@@ -1782,12 +1817,12 @@ function as(r) {
1782
1817
  break;
1783
1818
  }
1784
1819
  }
1785
- const v = {
1820
+ const E = {
1786
1821
  indent: !0,
1787
1822
  textOpen: n,
1788
1823
  textClose: null
1789
1824
  };
1790
- return u = Mt(v), d += u, {
1825
+ return u = Et(E), d += u, {
1791
1826
  type: y,
1792
1827
  name: w,
1793
1828
  path: M,
@@ -1798,15 +1833,15 @@ function as(r) {
1798
1833
  tokens: u,
1799
1834
  tokensChilds: f,
1800
1835
  tokensTotal: d,
1801
- text: v,
1836
+ text: E,
1802
1837
  size: p,
1803
- countFiles: h,
1838
+ countFiles: m,
1804
1839
  dateModified: g
1805
1840
  };
1806
1841
  };
1807
1842
  }
1808
- async function ls(r) {
1809
- const t = await rs(r), s = le(t), o = s.getChilds(s.root), e = It({
1843
+ async function hs(t) {
1844
+ const r = await ls(t), s = le(r), o = s.getChilds(s.root), e = vt({
1810
1845
  getId: (i) => {
1811
1846
  const a = s.getId(i);
1812
1847
  if (a == null)
@@ -1816,26 +1851,26 @@ async function ls(r) {
1816
1851
  return a;
1817
1852
  },
1818
1853
  getChilds: (i) => s.getChilds(i),
1819
- createSnapshotNode: as(r),
1854
+ createSnapshotNode: ps(t),
1820
1855
  rootNodes: o ?? []
1821
- }), n = is(e.idToNode);
1856
+ }), n = fs(e.idToNode);
1822
1857
  return e.idToChildIds.forEach((i) => {
1823
1858
  i.sort(n);
1824
1859
  }), le(e);
1825
1860
  }
1826
- const ee = m.object({
1827
- queryName: m.string().optional().describe("Name of previously created filesystem snapshot query, to use"),
1861
+ const ee = h.object({
1862
+ queryName: h.string().optional().describe("Name of previously created filesystem snapshot query, to use"),
1828
1863
  query: xe.optional().describe(
1829
1864
  "Filesystem snapshot query creation options JSON to automatically create query"
1830
1865
  ),
1831
- name: m.string().describe(
1866
+ name: h.string().describe(
1832
1867
  "Unique name for the filesystem snapshot. Recommended format: kebab-case-1, kebab-case-2, ..."
1833
1868
  )
1834
1869
  });
1835
- async function ce(r, t, s) {
1870
+ async function ce(t, r, s) {
1836
1871
  let o;
1837
1872
  try {
1838
- o = ee.parse(r);
1873
+ o = ee.parse(t);
1839
1874
  } catch (u) {
1840
1875
  return {
1841
1876
  error: F(u)
@@ -1860,9 +1895,9 @@ async function ce(r, t, s) {
1860
1895
  };
1861
1896
  c = u;
1862
1897
  } else if (i) {
1863
- const u = await xt(
1898
+ const u = await Tt(
1864
1899
  i,
1865
- t,
1900
+ r,
1866
1901
  s
1867
1902
  );
1868
1903
  if (u.error != null)
@@ -1875,7 +1910,7 @@ async function ce(r, t, s) {
1875
1910
  error: "Either queryName or query must be provided"
1876
1911
  };
1877
1912
  try {
1878
- const u = await ls(c), f = {
1913
+ const u = await hs(c), f = {
1879
1914
  name: e,
1880
1915
  query: c,
1881
1916
  tree: u
@@ -1890,8 +1925,8 @@ async function ce(r, t, s) {
1890
1925
  };
1891
1926
  }
1892
1927
  }
1893
- function cs(r, t) {
1894
- r(
1928
+ function ms(t, r) {
1929
+ t(
1895
1930
  "fs-snapshot-create",
1896
1931
  {
1897
1932
  title: "Create Filesystem Snapshot",
@@ -1899,7 +1934,7 @@ function cs(r, t) {
1899
1934
  inputSchema: ee.shape
1900
1935
  },
1901
1936
  async (s, o) => {
1902
- const e = await ce(s, t, o);
1937
+ const e = await ce(s, r, o);
1903
1938
  if (e.error != null)
1904
1939
  return `Method: fs-snapshot-create(${JSON.stringify(s)})
1905
1940
  ❌ Error: ${e.error}`;
@@ -1910,18 +1945,18 @@ function cs(r, t) {
1910
1945
  }
1911
1946
  );
1912
1947
  }
1913
- class us {
1948
+ class gs {
1914
1949
  _first = null;
1915
1950
  _last = null;
1916
1951
  _size = 0;
1917
- enqueue(t) {
1918
- const s = { item: t, next: null };
1952
+ enqueue(r) {
1953
+ const s = { item: r, next: null };
1919
1954
  this._last ? this._last.next = s : this._first = s, this._last = s, this._size += 1;
1920
1955
  }
1921
1956
  dequeue() {
1922
1957
  if (!this._first) return null;
1923
- const t = this._first.item;
1924
- return this._first = this._first.next, this._first || (this._last = null), this._size -= 1, t;
1958
+ const r = this._first.item;
1959
+ return this._first = this._first.next, this._first || (this._last = null), this._size -= 1, r;
1925
1960
  }
1926
1961
  peek() {
1927
1962
  return this._first ? this._first.item : null;
@@ -1933,34 +1968,34 @@ class us {
1933
1968
  return this._size;
1934
1969
  }
1935
1970
  }
1936
- function ds(r) {
1937
- const t = new us(), {
1971
+ function ws(t) {
1972
+ const r = new gs(), {
1938
1973
  tree: s,
1939
1974
  limits: { maxCountTotal: o, maxTokensTotal: e, maxCountGroup: n, maxTokensGroup: i },
1940
1975
  indexRangeGroupStrategy: a
1941
- } = r, c = s.getChilds(s.root);
1942
- c != null && c.length > 0 && t.enqueue({
1976
+ } = t, c = s.getChilds(s.root);
1977
+ c != null && c.length > 0 && r.enqueue({
1943
1978
  reportNode: null,
1944
1979
  node: s.root
1945
1980
  });
1946
1981
  let l = null, u = 0, f = 0;
1947
- for (; !t.isEmpty(); ) {
1948
- const { reportNode: d, node: p } = t.dequeue(), h = s.getChilds(p);
1949
- if (h == null || p.countChilds === 0 || h.length !== p.countChilds)
1982
+ for (; !r.isEmpty(); ) {
1983
+ const { reportNode: d, node: p } = r.dequeue(), m = s.getChilds(p);
1984
+ if (m == null || p.countChilds === 0 || m.length !== p.countChilds)
1950
1985
  throw new Error(
1951
1986
  "Impossible behavior: nodeChilds is null or length mismatch"
1952
1987
  );
1953
- let g = t.size();
1954
- for (let w = 0; w < h.length; w++)
1955
- h[w].countChilds > 0 && (g += 1);
1988
+ let g = r.size();
1989
+ for (let w = 0; w < m.length; w++)
1990
+ m[w].countChilds > 0 && (g += 1);
1956
1991
  const y = g * a.tokens;
1957
1992
  if (o != null && u + p.countChilds + g > o || e != null && f + p.tokensChilds + y > e) {
1958
1993
  const w = [];
1959
- let M = null, v = 0;
1960
- for (let $ = 0, T = h.length; $ < T; $++) {
1961
- const x = h[$], S = v * a.tokens;
1994
+ let M = null, E = 0;
1995
+ for (let $ = 0, T = m.length; $ < T; $++) {
1996
+ const x = m[$], S = E * a.tokens;
1962
1997
  M != null && // Если общий лимит превышен, то не создаем новую группу, а продолжаем текущую. В случае достижения лимитов, последняя группа может содержать больше элементов, чем указано в лимитах группы, и это допустимо. Главное - дать в отчете полную картину.
1963
- !(o != null && u + 1 > o || e != null && f + a.tokens > e) && (n != null && M.countGrouped + 1 + v > n || i != null && M.tokensGrouped + x.tokens + S > i) && (w.push(M), u += 1, f += a.tokens, M = null, v = 0), M = a.add(M, x, $), x.countChilds > 0 && (v += 1);
1998
+ !(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);
1964
1999
  }
1965
2000
  M != null && (w.push(M), u += 1, f += a.tokens);
1966
2001
  const b = w.map(($) => ({
@@ -1978,15 +2013,15 @@ function ds(r) {
1978
2013
  } else {
1979
2014
  u += p.countChilds, f += p.tokensChilds;
1980
2015
  const w = [];
1981
- for (let M = 0; M < h.length; M++) {
1982
- const v = h[M], b = {
1983
- text: v.text
2016
+ for (let M = 0; M < m.length; M++) {
2017
+ const E = m[M], b = {
2018
+ text: E.text
1984
2019
  };
1985
2020
  w.push(b);
1986
- const $ = s.getChilds(v);
1987
- $ != null && $.length > 0 && t.enqueue({
2021
+ const $ = s.getChilds(E);
2022
+ $ != null && $.length > 0 && r.enqueue({
1988
2023
  reportNode: b,
1989
- node: v
2024
+ node: E
1990
2025
  });
1991
2026
  }
1992
2027
  if (d != null) {
@@ -2002,35 +2037,35 @@ function ds(r) {
2002
2037
  }
2003
2038
  return l ?? [];
2004
2039
  }
2005
- function Tt(r) {
2040
+ function Nt(t) {
2006
2041
  const {
2007
- tree: t,
2042
+ tree: r,
2008
2043
  request: { parentNodeId: s, childsIndexRange: o, limits: e },
2009
2044
  indexRangeGroupStrategy: n,
2010
2045
  ...i
2011
- } = r;
2046
+ } = t;
2012
2047
  let a;
2013
2048
  if (s != null) {
2014
- const d = t.getNode(s);
2049
+ const d = r.getNode(s);
2015
2050
  if (d == null)
2016
2051
  throw new Error(`Parent node "${s}" not found`);
2017
2052
  a = d;
2018
2053
  } else
2019
- a = t.root;
2020
- let c, l = t.getChilds(a) ?? [];
2054
+ a = r.root;
2055
+ let c, l = r.getChilds(a) ?? [];
2021
2056
  if (o != null) {
2022
2057
  const [d, p] = o;
2023
2058
  if (d < 0 || p <= d || p >= l.length)
2024
2059
  throw new Error(
2025
2060
  `Invalid index range: ${d}-${p} for root nodes length ${l.length}`
2026
2061
  );
2027
- const h = [];
2062
+ const m = [];
2028
2063
  let g = null;
2029
2064
  for (let y = d; y <= p; y++) {
2030
2065
  const w = l[y];
2031
- h.push(w), g = n.add(g, w, y);
2066
+ m.push(w), g = n.add(g, w, y);
2032
2067
  }
2033
- l = h, c = {
2068
+ l = m, c = {
2034
2069
  ...a,
2035
2070
  text: n.getReportText(g),
2036
2071
  countChilds: g.countGrouped,
@@ -2042,19 +2077,19 @@ function Tt(r) {
2042
2077
  countChilds: 1,
2043
2078
  tokensChilds: c.tokens
2044
2079
  }, f = {
2045
- ...t,
2080
+ ...r,
2046
2081
  root: u,
2047
- getChilds: (d) => d === u ? [c] : d === c ? l : t.getChilds(d)
2082
+ getChilds: (d) => d === u ? [c] : d === c ? l : r.getChilds(d)
2048
2083
  };
2049
- return ds({
2084
+ return ws({
2050
2085
  tree: f,
2051
2086
  limits: e,
2052
2087
  indexRangeGroupStrategy: n,
2053
2088
  ...i
2054
2089
  });
2055
2090
  }
2056
- function Ct(r, t) {
2057
- if (r == null || r.length === 0)
2091
+ function kt(t, r) {
2092
+ if (t == null || t.length === 0)
2058
2093
  return "No results found";
2059
2094
  let s = "";
2060
2095
  function o(e, n) {
@@ -2068,32 +2103,32 @@ function Ct(r, t) {
2068
2103
  `);
2069
2104
  }
2070
2105
  }
2071
- return o(r, ""), s;
2106
+ return o(t, ""), s;
2072
2107
  }
2073
- class fs {
2108
+ class ys {
2074
2109
  tokens = 16;
2075
2110
  // +1 indent, +1 for line break
2076
- getReportText = (t) => ({
2111
+ getReportText = (r) => ({
2077
2112
  indent: !0,
2078
- textOpen: `[${t.indexRange[0]}-${t.indexRange[1]}] see more ${t.countMatched} matched ${t.tokensGrouped} tokens`,
2113
+ textOpen: `[${r.indexRange[0]}-${r.indexRange[1]}] see more ${r.countMatched} matched ${r.tokensGrouped} tokens`,
2079
2114
  textClose: null
2080
2115
  });
2081
- add = (t, s, o) => t == null ? {
2116
+ add = (r, s, o) => r == null ? {
2082
2117
  indexRange: [o, o],
2083
2118
  countGrouped: 1,
2084
2119
  countMatched: s.countMatched,
2085
2120
  tokensGrouped: s.tokens
2086
- } : (t.indexRange[1] = o, t.countGrouped += 1, t.countMatched += s.countMatched, t.tokensGrouped += s.tokens, t);
2121
+ } : (r.indexRange[1] = o, r.countGrouped += 1, r.countMatched += s.countMatched, r.tokensGrouped += s.tokens, r);
2087
2122
  }
2088
- const Et = m.object({
2089
- snapshotName: m.string().optional().describe("Name of previously created filesystem snapshot, to use"),
2123
+ const Ot = h.object({
2124
+ snapshotName: h.string().optional().describe("Name of previously created filesystem snapshot, to use"),
2090
2125
  snapshot: ee.optional().describe(
2091
2126
  "Filesystem snapshot creation options JSON to automatically create snapshot"
2092
2127
  ),
2093
- parentPath: m.string().optional().describe(
2128
+ parentPath: h.string().optional().describe(
2094
2129
  "Path relative to snapshot rootDir to browse. Omit to browse the rootDir itself"
2095
2130
  ),
2096
- childsIndexRange: m.tuple([m.number(), m.number()]).optional().describe(
2131
+ childsIndexRange: h.tuple([h.number(), h.number()]).optional().describe(
2097
2132
  "Child index range to show [start, end]. Only use the exact ranges that appeared in previous snapshot results - do not modify, combine, or split them"
2098
2133
  )
2099
2134
  // maxCountTotal: z
@@ -2107,10 +2142,10 @@ const Et = m.object({
2107
2142
  // maxCountGroup: z.number().default(10).describe('Maximum items per group'),
2108
2143
  // maxTokensGroup: z.number().default(1000).describe('Maximum tokens per group'),
2109
2144
  });
2110
- async function ps(r, t, s) {
2145
+ async function bs(t, r, s) {
2111
2146
  let o;
2112
2147
  try {
2113
- o = Et.parse(r);
2148
+ o = Ot.parse(t);
2114
2149
  } catch (g) {
2115
2150
  return {
2116
2151
  error: F(g)
@@ -2134,7 +2169,7 @@ async function ps(r, t, s) {
2134
2169
  return {
2135
2170
  error: "Either snapshotName or snapshot must be provided, not both"
2136
2171
  };
2137
- let d, p = !1, h = !1;
2172
+ let d, p = !1, m = !1;
2138
2173
  if (e) {
2139
2174
  if (d = f.fsSnapshots.get(e), d == null)
2140
2175
  return {
@@ -2143,20 +2178,20 @@ async function ps(r, t, s) {
2143
2178
  } else if (n) {
2144
2179
  const g = await ce(
2145
2180
  n,
2146
- t,
2181
+ r,
2147
2182
  s
2148
2183
  );
2149
2184
  if (g.error != null)
2150
2185
  return {
2151
2186
  error: g.error
2152
2187
  };
2153
- d = g.fsSnapshot, p = g.queryCreated, h = !0;
2188
+ d = g.fsSnapshot, p = g.queryCreated, m = !0;
2154
2189
  } else
2155
2190
  return {
2156
2191
  error: "Either snapshotName or snapshot must be provided"
2157
2192
  };
2158
2193
  try {
2159
- const g = me(o.parentPath), y = Tt({
2194
+ const g = me(o.parentPath), y = Nt({
2160
2195
  tree: d.tree,
2161
2196
  request: {
2162
2197
  parentNodeId: g,
@@ -2168,12 +2203,12 @@ async function ps(r, t, s) {
2168
2203
  maxTokensGroup: u
2169
2204
  }
2170
2205
  },
2171
- indexRangeGroupStrategy: new fs()
2172
- }), w = Ct(y);
2206
+ indexRangeGroupStrategy: new ys()
2207
+ }), w = kt(y);
2173
2208
  return {
2174
2209
  fsSnapshot: d,
2175
2210
  queryCreated: p,
2176
- snapshotCreated: h,
2211
+ snapshotCreated: m,
2177
2212
  parentPath: g,
2178
2213
  childsIndexRange: i,
2179
2214
  report: w
@@ -2184,16 +2219,16 @@ async function ps(r, t, s) {
2184
2219
  };
2185
2220
  }
2186
2221
  }
2187
- function hs(r, t) {
2188
- r(
2222
+ function Ss(t, r) {
2223
+ t(
2189
2224
  "fs-snapshot-browse",
2190
2225
  {
2191
2226
  title: "Browse Filesystem Snapshot",
2192
2227
  description: "Browse and explore filesystem. Use this to efficiently browse, analyze, explore, inspect, etc directory and file structures",
2193
- inputSchema: Et.shape
2228
+ inputSchema: Ot.shape
2194
2229
  },
2195
2230
  async (s, o) => {
2196
- const e = await ps(s, t, o);
2231
+ const e = await bs(s, r, o);
2197
2232
  if (e.error != null)
2198
2233
  return `Method: fs-snapshot-browse(${JSON.stringify(s)})
2199
2234
  ❌ Error: ${e.error}`;
@@ -2215,26 +2250,26 @@ ${e.report}`, n;
2215
2250
  }
2216
2251
  );
2217
2252
  }
2218
- function vt(r) {
2219
- const t = [], s = r.tree, o = r.query.rootDir ?? ".";
2253
+ function Rt(t) {
2254
+ const r = [], s = t.tree, o = t.query.rootDir ?? ".";
2220
2255
  function e(n) {
2221
- n.type === "file" && n.isMatched && t.push(o + "/" + n.path);
2256
+ n.type === "file" && n.isMatched && r.push(o + "/" + n.path);
2222
2257
  const i = s.getChilds(n);
2223
2258
  if (i != null)
2224
2259
  for (let a = 0; a < i.length; a++)
2225
2260
  e(i[a]);
2226
2261
  }
2227
- return e(s.root), t;
2262
+ return e(s.root), r;
2228
2263
  }
2229
- const He = /* @__PURE__ */ new Map();
2230
- function ms(r) {
2231
- const t = H(r);
2232
- let s = He.get(t);
2233
- return s == null && (s = new er(), He.set(t, s)), s;
2264
+ const Ve = /* @__PURE__ */ new Map();
2265
+ function xs(t) {
2266
+ const r = H(t);
2267
+ let s = Ve.get(r);
2268
+ return s == null && (s = new or(), Ve.set(r, s)), s;
2234
2269
  }
2235
- async function gs(r) {
2236
- const { filePath: t, func: s } = r;
2237
- return ms(t).lock(
2270
+ async function $s(t) {
2271
+ const { filePath: r, func: s } = t;
2272
+ return xs(r).lock(
2238
2273
  () => V({
2239
2274
  pool: Se,
2240
2275
  count: 1,
@@ -2242,11 +2277,11 @@ async function gs(r) {
2242
2277
  })
2243
2278
  );
2244
2279
  }
2245
- const Qe = 10, re = 48, Ye = 57, de = 36, ws = 38, ys = 39, bs = 60, Ss = 62, xs = 96, se = 0, Ve = 1, Ze = 2, Xe = 3, et = 4, $s = 5;
2246
- function Is(r) {
2247
- const { content: t, pattern: s, replacement: o } = r, e = t.length, n = [0];
2280
+ const Ze = 10, re = 48, Xe = 57, de = 36, Is = 38, Ms = 39, Ts = 60, Cs = 62, vs = 96, se = 0, et = 1, tt = 2, rt = 3, st = 4, Es = 5;
2281
+ function Ns(t) {
2282
+ const { content: r, pattern: s, replacement: o } = t, e = r.length, n = [0];
2248
2283
  for (let b = 0; b < e; b++)
2249
- t.charCodeAt(b) === Qe && b + 1 < e && n.push(b + 1);
2284
+ r.charCodeAt(b) === Ze && b + 1 < e && n.push(b + 1);
2250
2285
  const i = n.length, a = [], c = [];
2251
2286
  let l = null, u = null, f = null, d = 0;
2252
2287
  if (o != null) {
@@ -2266,43 +2301,43 @@ function Is(r) {
2266
2301
  continue;
2267
2302
  }
2268
2303
  const S = o.charCodeAt(x + 1);
2269
- let E = -1, B = 0, O = 2;
2304
+ let v = -1, B = 0, O = 2;
2270
2305
  if (S === de)
2271
- E = se, B = "$";
2272
- else if (S === ws)
2273
- E = Ve;
2274
- else if (S === xs)
2275
- E = Ze;
2276
- else if (S === ys)
2277
- E = Xe;
2278
- else if (S >= re && S <= Ye) {
2306
+ v = se, B = "$";
2307
+ else if (S === Is)
2308
+ v = et;
2309
+ else if (S === vs)
2310
+ v = tt;
2311
+ else if (S === Ms)
2312
+ v = rt;
2313
+ else if (S >= re && S <= Xe) {
2279
2314
  let I = x + 2;
2280
2315
  for (; I < b; ) {
2281
2316
  const C = o.charCodeAt(I);
2282
- if (C < re || C > Ye) break;
2317
+ if (C < re || C > Xe) break;
2283
2318
  I++;
2284
2319
  }
2285
- E = et, B = o.substring(x + 1, I), O = I - x;
2286
- } else if (S === bs) {
2320
+ v = st, B = o.substring(x + 1, I), O = I - x;
2321
+ } else if (S === Ts) {
2287
2322
  let I = x + 2;
2288
- for (; I < b && o.charCodeAt(I) !== Ss; )
2323
+ for (; I < b && o.charCodeAt(I) !== Cs; )
2289
2324
  I++;
2290
- I < b && I > x + 2 && (E = $s, B = o.substring(x + 2, I), O = I + 1 - x);
2325
+ I < b && I > x + 2 && (v = Es, B = o.substring(x + 2, I), O = I + 1 - x);
2291
2326
  }
2292
- E >= 0 ? (x > T && (u.push(se), f.push(o.substring(T, x))), u.push(E), f.push(B), x += O, T = x) : x++;
2327
+ v >= 0 ? (x > T && (u.push(se), f.push(o.substring(T, x))), u.push(v), f.push(B), x += O, T = x) : x++;
2293
2328
  }
2294
2329
  T < b && (u.push(se), f.push(o.substring(T))), d = u.length;
2295
2330
  } else
2296
2331
  l = o;
2297
2332
  }
2298
- let p = "", h = 0, g = 0;
2333
+ let p = "", m = 0, g = 0;
2299
2334
  s.lastIndex = 0;
2300
2335
  let y;
2301
- for (; (y = s.exec(t)) !== null; ) {
2336
+ for (; (y = s.exec(r)) !== null; ) {
2302
2337
  const b = y.index, $ = y[0], T = $.length, x = b + T;
2303
- let S, E, B, O;
2338
+ let S, v, B, O;
2304
2339
  if (i === 1)
2305
- S = 0, E = 1, B = 0, O = e;
2340
+ S = 0, v = 1, B = 0, O = e;
2306
2341
  else {
2307
2342
  let I = 0, C = i - 1;
2308
2343
  for (; I < C; ) {
@@ -2312,51 +2347,51 @@ function Is(r) {
2312
2347
  if (S = I, T > 0) {
2313
2348
  const N = x - 1;
2314
2349
  for (C = i - 1; I < C; ) {
2315
- const D = I + C + 1 >> 1;
2316
- n[D] <= N ? I = D : C = D - 1;
2350
+ const R = I + C + 1 >> 1;
2351
+ n[R] <= N ? I = R : C = R - 1;
2317
2352
  }
2318
- E = I + 1;
2353
+ v = I + 1;
2319
2354
  } else
2320
- E = S + 1;
2321
- B = n[S], O = E < i ? n[E] : e;
2355
+ v = S + 1;
2356
+ B = n[S], O = v < i ? n[v] : e;
2322
2357
  }
2323
2358
  if (a.push({
2324
2359
  offset: [b, x],
2325
- lines: [S, E],
2360
+ lines: [S, v],
2326
2361
  linesOffset: [B, O]
2327
2362
  }), o != null) {
2328
- p += t.substring(h, b);
2363
+ p += r.substring(m, b);
2329
2364
  let I;
2330
2365
  if (l != null)
2331
2366
  I = l;
2332
2367
  else {
2333
2368
  I = "";
2334
- const N = y.groups, D = y.length - 1;
2369
+ const N = y.groups, R = y.length - 1;
2335
2370
  for (let K = 0; K < d; K++) {
2336
2371
  const q = u[K], P = f[K];
2337
2372
  switch (q) {
2338
2373
  case se:
2339
2374
  I += P;
2340
2375
  break;
2341
- case Ve:
2376
+ case et:
2342
2377
  I += $;
2343
2378
  break;
2344
- case Ze:
2345
- I += t.substring(0, b);
2379
+ case tt:
2380
+ I += r.substring(0, b);
2346
2381
  break;
2347
- case Xe:
2348
- I += t.substring(x);
2382
+ case rt:
2383
+ I += r.substring(x);
2349
2384
  break;
2350
- case et: {
2385
+ case st: {
2351
2386
  const L = P, z = L.length, A = L.charCodeAt(0) - re;
2352
2387
  if (z >= 2) {
2353
- const G = L.charCodeAt(1) - re, R = A * 10 + G;
2354
- if (R >= 1 && R <= D) {
2355
- I += y[R] ?? "", z > 2 && (I += L.substring(2));
2388
+ const _ = L.charCodeAt(1) - re, D = A * 10 + _;
2389
+ if (D >= 1 && D <= R) {
2390
+ I += y[D] ?? "", z > 2 && (I += L.substring(2));
2356
2391
  break;
2357
2392
  }
2358
2393
  }
2359
- A >= 1 && A <= D ? (I += y[A] ?? "", z > 1 && (I += L.substring(1))) : I += "$" + L;
2394
+ A >= 1 && A <= R ? (I += y[A] ?? "", z > 1 && (I += L.substring(1))) : I += "$" + L;
2360
2395
  break;
2361
2396
  }
2362
2397
  default:
@@ -2370,60 +2405,60 @@ function Is(r) {
2370
2405
  offset: [C, C + I.length],
2371
2406
  lines: [0, 0],
2372
2407
  linesOffset: [0, 0]
2373
- }), g += I.length - T, h = x;
2408
+ }), g += I.length - T, m = x;
2374
2409
  }
2375
2410
  if (T === 0 && s.lastIndex++, !s.global)
2376
2411
  break;
2377
2412
  }
2378
2413
  if (s.lastIndex = 0, o == null)
2379
- return { search: { content: t, matches: a }, replace: null };
2380
- p += t.substring(h);
2414
+ return { search: { content: r, matches: a }, replace: null };
2415
+ p += r.substring(m);
2381
2416
  const w = p.length, M = [0];
2382
2417
  for (let b = 0; b < w; b++)
2383
- p.charCodeAt(b) === Qe && b + 1 < w && M.push(b + 1);
2384
- const v = M.length;
2418
+ p.charCodeAt(b) === Ze && b + 1 < w && M.push(b + 1);
2419
+ const E = M.length;
2385
2420
  for (let b = 0, $ = c.length; b < $; b++) {
2386
2421
  const T = c[b], x = T.offset[0], S = T.offset[1];
2387
- let E, B, O, I;
2388
- if (v === 1)
2389
- E = 0, B = 1, O = 0, I = w;
2422
+ let v, B, O, I;
2423
+ if (E === 1)
2424
+ v = 0, B = 1, O = 0, I = w;
2390
2425
  else {
2391
- let C = 0, N = v - 1;
2426
+ let C = 0, N = E - 1;
2392
2427
  for (; C < N; ) {
2393
- const D = C + N + 1 >> 1;
2394
- M[D] <= x ? C = D : N = D - 1;
2428
+ const R = C + N + 1 >> 1;
2429
+ M[R] <= x ? C = R : N = R - 1;
2395
2430
  }
2396
- if (E = C, S > x) {
2397
- const D = S - 1;
2398
- for (N = v - 1; C < N; ) {
2431
+ if (v = C, S > x) {
2432
+ const R = S - 1;
2433
+ for (N = E - 1; C < N; ) {
2399
2434
  const K = C + N + 1 >> 1;
2400
- M[K] <= D ? C = K : N = K - 1;
2435
+ M[K] <= R ? C = K : N = K - 1;
2401
2436
  }
2402
2437
  B = C + 1;
2403
2438
  } else
2404
- B = E + 1;
2405
- O = M[E], I = B < v ? M[B] : w;
2439
+ B = v + 1;
2440
+ O = M[v], I = B < E ? M[B] : w;
2406
2441
  }
2407
- T.lines[0] = E, T.lines[1] = B, T.linesOffset[0] = O, T.linesOffset[1] = I;
2442
+ T.lines[0] = v, T.lines[1] = B, T.linesOffset[0] = O, T.linesOffset[1] = I;
2408
2443
  }
2409
2444
  return {
2410
- search: { content: t, matches: a },
2445
+ search: { content: r, matches: a },
2411
2446
  replace: { content: p, matches: c }
2412
2447
  };
2413
2448
  }
2414
- function Nt(r) {
2415
- if (r.length === 0)
2449
+ function Dt(t) {
2450
+ if (t.length === 0)
2416
2451
  return [];
2417
- const t = [...r].sort((i, a) => {
2452
+ const r = [...t].sort((i, a) => {
2418
2453
  const c = i.lines[0], l = a.lines[0];
2419
2454
  if (c > l) return 1;
2420
2455
  if (c < l) return -1;
2421
2456
  const u = i.lines[1], f = a.lines[1];
2422
2457
  return u > f ? 1 : u < f ? -1 : 0;
2423
2458
  }), s = [];
2424
- let o = [...t[0].offset], e = [...t[0].lines], n = [...t[0].linesOffset];
2425
- for (let i = 1; i < t.length; i++) {
2426
- const a = t[i];
2459
+ let o = [...r[0].offset], e = [...r[0].lines], n = [...r[0].linesOffset];
2460
+ for (let i = 1; i < r.length; i++) {
2461
+ const a = r[i];
2427
2462
  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({
2428
2463
  offset: o,
2429
2464
  lines: e,
@@ -2436,91 +2471,91 @@ function Nt(r) {
2436
2471
  linesOffset: n
2437
2472
  }), s;
2438
2473
  }
2439
- function oe(r, t, s, o) {
2474
+ function oe(t, r, s, o) {
2440
2475
  let e = 0, n = 0;
2441
2476
  for (let u = 0; u < s; u++)
2442
- r.charCodeAt(u) === 10 && (n = u + 1, e++);
2477
+ t.charCodeAt(u) === 10 && (n = u + 1, e++);
2443
2478
  const i = e, a = n;
2444
2479
  let c = s;
2445
2480
  for (; c < o; c++)
2446
- r.charCodeAt(c) === 10 && e++;
2481
+ t.charCodeAt(c) === 10 && e++;
2447
2482
  const l = e + 1;
2448
- for (; c < t; c++)
2449
- if (r.charCodeAt(c) === 10)
2483
+ for (; c < r; c++)
2484
+ if (t.charCodeAt(c) === 10)
2450
2485
  return { startLine: i, endLine: l, startLineOfs: a, endLineOfs: c + 1 };
2451
- return { startLine: i, endLine: l, startLineOfs: a, endLineOfs: t };
2486
+ return { startLine: i, endLine: l, startLineOfs: a, endLineOfs: r };
2452
2487
  }
2453
- function Ms(r, t) {
2454
- if (r.replace == null && t.replace == null) {
2455
- const U = [...r.search.matches, ...t.search.matches];
2488
+ function ks(t, r) {
2489
+ if (t.replace == null && r.replace == null) {
2490
+ const U = [...t.search.matches, ...r.search.matches];
2456
2491
  return {
2457
- search: { content: r.search.content, matches: Nt(U) },
2492
+ search: { content: t.search.content, matches: Dt(U) },
2458
2493
  replace: null
2459
2494
  };
2460
2495
  }
2461
- 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 = [];
2462
- let y = 0, w = 0, M = 0, v = 0, b = 0, $ = 0, T = 0, x = 0, S = 0, E = 0, B = 0, O = 0, I = 0, C = 0, N = 0, D = 0, K = 0, q = 0, P = 0, L = 0, z = 0, A = 0, G = 0, R = 0;
2496
+ 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, m = [], g = [];
2497
+ let y = 0, w = 0, M = 0, E = 0, b = 0, $ = 0, T = 0, x = 0, S = 0, v = 0, B = 0, O = 0, I = 0, C = 0, N = 0, R = 0, K = 0, q = 0, P = 0, L = 0, z = 0, A = 0, _ = 0, D = 0;
2463
2498
  for (; y < d || w < p; )
2464
2499
  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 < $) {
2465
2500
  K = b < T ? b : T, S = $ > x ? $ : x, B = y, O = w, y++, w++;
2466
2501
  do {
2467
- for (E = S; y < d && l[y].offset[0] < S; )
2502
+ for (v = S; y < d && l[y].offset[0] < S; )
2468
2503
  $ = l[y].offset[1], $ > S && (S = $), y++;
2469
2504
  for (; w < p && u[w].offset[0] < S; )
2470
2505
  x = u[w].offset[1], x > S && (S = x), w++;
2471
- } while (S !== E);
2506
+ } while (S !== v);
2472
2507
  I = 1 / 0, C = -1 / 0, q = K, P = M;
2473
- for (let _ = B; _ < y; _++)
2474
- L = c[_].offset[0], z = c[_].offset[1], A = l[_].offset[0], G = l[_].offset[1], q < A && (R = q + P, R < I && (I = R), R = A + P, R > C && (C = R)), L < I && (I = L), z > C && (C = z), P += z - L - G + A, q = G;
2475
- q < S && (R = q + P, R < I && (I = R), R = S + P, R > C && (C = R)), M = P, N = 1 / 0, D = -1 / 0, q = K, P = v;
2476
- for (let _ = O; _ < w; _++)
2477
- L = u[_].offset[0], z = u[_].offset[1], A = f[_].offset[0], G = f[_].offset[1], q < L && (R = q + P, R < N && (N = R), R = L + P, R > D && (D = R)), A < N && (N = A), G > D && (D = G), P += G - A - z + L, q = z;
2478
- q < S && (R = q + P, R < N && (N = R), R = S + P, R > D && (D = R)), v = P;
2508
+ for (let G = B; G < y; G++)
2509
+ L = c[G].offset[0], z = c[G].offset[1], A = l[G].offset[0], _ = l[G].offset[1], q < A && (D = q + P, D < I && (I = D), D = A + P, D > C && (C = D)), L < I && (I = L), z > C && (C = z), P += z - L - _ + A, q = _;
2510
+ q < S && (D = q + P, D < I && (I = D), D = S + P, D > C && (C = D)), M = P, N = 1 / 0, R = -1 / 0, q = K, P = E;
2511
+ for (let G = O; G < w; G++)
2512
+ L = u[G].offset[0], z = u[G].offset[1], A = f[G].offset[0], _ = f[G].offset[1], q < L && (D = q + P, D < N && (N = D), D = L + P, D > R && (R = D)), A < N && (N = A), _ > R && (R = _), P += _ - A - z + L, q = z;
2513
+ q < S && (D = q + P, D < N && (N = D), D = S + P, D > R && (R = D)), E = P;
2479
2514
  const U = oe(e, i, I, C);
2480
- h.push({
2515
+ m.push({
2481
2516
  offset: [I, C],
2482
2517
  lines: [U.startLine, U.endLine],
2483
2518
  linesOffset: [U.startLineOfs, U.endLineOfs]
2484
2519
  });
2485
- const te = oe(n, a, N, D);
2520
+ const te = oe(n, a, N, R);
2486
2521
  g.push({
2487
- offset: [N, D],
2522
+ offset: [N, R],
2488
2523
  lines: [te.startLine, te.endLine],
2489
2524
  linesOffset: [te.startLineOfs, te.endLineOfs]
2490
2525
  });
2491
2526
  } else if (w >= p || y < d && b <= T) {
2492
- L = c[y].offset[0], z = c[y].offset[1], A = l[y].offset[0], G = l[y].offset[1], N = A + v, D = G + v;
2493
- const U = oe(n, a, N, D);
2494
- h.push(c[y]), g.push({
2495
- offset: [N, D],
2527
+ L = c[y].offset[0], z = c[y].offset[1], A = l[y].offset[0], _ = l[y].offset[1], N = A + E, R = _ + E;
2528
+ const U = oe(n, a, N, R);
2529
+ m.push(c[y]), g.push({
2530
+ offset: [N, R],
2496
2531
  lines: [U.startLine, U.endLine],
2497
2532
  linesOffset: [U.startLineOfs, U.endLineOfs]
2498
- }), M += z - L - G + A, y++;
2533
+ }), M += z - L - _ + A, y++;
2499
2534
  } else {
2500
- L = u[w].offset[0], z = u[w].offset[1], A = f[w].offset[0], G = f[w].offset[1], I = L + M, C = z + M;
2535
+ L = u[w].offset[0], z = u[w].offset[1], A = f[w].offset[0], _ = f[w].offset[1], I = L + M, C = z + M;
2501
2536
  const U = oe(e, i, I, C);
2502
- h.push({
2537
+ m.push({
2503
2538
  offset: [I, C],
2504
2539
  lines: [U.startLine, U.endLine],
2505
2540
  linesOffset: [U.startLineOfs, U.endLineOfs]
2506
- }), g.push(f[w]), v += G - A - z + L, w++;
2541
+ }), g.push(f[w]), E += _ - A - z + L, w++;
2507
2542
  }
2508
2543
  return {
2509
- search: { content: e, matches: h },
2544
+ search: { content: e, matches: m },
2510
2545
  replace: { content: n, matches: g }
2511
2546
  };
2512
2547
  }
2513
- async function Ts(r) {
2514
- const { filePath: t, operations: s, dryRun: o } = r;
2515
- return s.length === 0 ? { filePath: t, result: null } : gs({
2516
- filePath: t,
2548
+ async function Os(t) {
2549
+ const { filePath: r, operations: s, dryRun: o } = t;
2550
+ return s.length === 0 ? { filePath: r, result: null } : $s({
2551
+ filePath: r,
2517
2552
  func: async () => {
2518
2553
  let e;
2519
2554
  try {
2520
- e = await j.promises.readFile(t, "utf-8");
2555
+ e = await j.promises.readFile(r, "utf-8");
2521
2556
  } catch (a) {
2522
2557
  return {
2523
- filePath: t,
2558
+ filePath: r,
2524
2559
  result: null,
2525
2560
  error: `Failed to read file: ${a instanceof Error ? a.message : a + ""}`
2526
2561
  };
@@ -2533,39 +2568,39 @@ async function Ts(r) {
2533
2568
  l = new RegExp(c.pattern, c.flags ?? "");
2534
2569
  } catch (d) {
2535
2570
  return {
2536
- filePath: t,
2571
+ filePath: r,
2537
2572
  result: null,
2538
2573
  error: `Invalid RegExp pattern "${c.pattern}": ${d instanceof Error ? d.message : d + ""}`
2539
2574
  };
2540
2575
  }
2541
- const u = n?.replace?.content ?? e, f = Is({
2576
+ const u = n?.replace?.content ?? e, f = Ns({
2542
2577
  content: u,
2543
2578
  pattern: l,
2544
2579
  replacement: c.replacement
2545
2580
  });
2546
- c.replacement != null && (i = !0), n == null ? n = f : n = Ms(n, f);
2581
+ c.replacement != null && (i = !0), n == null ? n = f : n = ks(n, f);
2547
2582
  }
2548
2583
  if (i && n?.replace != null && !o) {
2549
2584
  const a = n.replace.content;
2550
2585
  if (a !== e)
2551
2586
  try {
2552
- await j.promises.writeFile(t, a, "utf-8");
2587
+ await j.promises.writeFile(r, a, "utf-8");
2553
2588
  } catch (c) {
2554
2589
  return {
2555
- filePath: t,
2590
+ filePath: r,
2556
2591
  result: n,
2557
2592
  error: `Failed to write file: ${c instanceof Error ? c.message : c + ""}`
2558
2593
  };
2559
2594
  }
2560
2595
  }
2561
- return { filePath: t, result: n };
2596
+ return { filePath: r, result: n };
2562
2597
  }
2563
2598
  });
2564
2599
  }
2565
- async function $e(r) {
2566
- const { filePaths: t, operations: s, dryRun: o, dateModifiedMax: e } = r;
2600
+ async function $e(t) {
2601
+ const { filePaths: r, operations: s, dryRun: o, dateModifiedMax: e } = t;
2567
2602
  return { results: await Promise.all(
2568
- t.map(async (i) => {
2603
+ r.map(async (i) => {
2569
2604
  if (e != null) {
2570
2605
  const a = await j.promises.stat(i).catch(() => null);
2571
2606
  if (a == null)
@@ -2581,34 +2616,34 @@ async function $e(r) {
2581
2616
  error: "Not replaced, try again"
2582
2617
  };
2583
2618
  }
2584
- return Ts({ filePath: i, operations: s, dryRun: o });
2619
+ return Os({ filePath: i, operations: s, dryRun: o });
2585
2620
  })
2586
2621
  ) };
2587
2622
  }
2588
- const Cs = 6;
2589
- function Es(r) {
2590
- const { content: t, startLine: s } = r, o = r.padWidth ?? Cs;
2623
+ const Rs = 6;
2624
+ function Ds(t) {
2625
+ const { content: r, startLine: s } = t, o = t.padWidth ?? Rs;
2591
2626
  let e = "", n = 0, i = 0;
2592
- for (; n < t.length; ) {
2593
- const a = t.indexOf(`
2594
- `, n), c = a === -1 ? t.length : a + 1;
2595
- e += String(s + i + 1).padStart(o) + "→" + t.substring(n, c), n = c, i++;
2627
+ for (; n < r.length; ) {
2628
+ const a = r.indexOf(`
2629
+ `, n), c = a === -1 ? r.length : a + 1;
2630
+ e += String(s + i + 1).padStart(o) + "→" + r.substring(n, c), n = c, i++;
2596
2631
  }
2597
2632
  return e.length > 0 && !e.endsWith(`
2598
2633
  `) && (e += `
2599
2634
  `), e;
2600
2635
  }
2601
- function fe(r) {
2602
- const { content: t, matches: s, outputLimit: o } = r;
2636
+ function fe(t) {
2637
+ const { content: r, matches: s, outputLimit: o } = t;
2603
2638
  if (s.length === 0)
2604
2639
  return { output: "", truncated: !1 };
2605
- const e = Nt(s);
2640
+ const e = Dt(s);
2606
2641
  let n = "", i = !1;
2607
2642
  for (let a = 0; a < e.length; a++) {
2608
- const c = e[a], l = t.substring(
2643
+ const c = e[a], l = r.substring(
2609
2644
  c.linesOffset[0],
2610
2645
  c.linesOffset[1]
2611
- ), u = Es({
2646
+ ), u = Ds({
2612
2647
  content: l,
2613
2648
  startLine: c.lines[0]
2614
2649
  }), f = a > 0 ? 2 : 0;
@@ -2621,40 +2656,40 @@ function fe(r) {
2621
2656
  }
2622
2657
  return { output: n, truncated: i };
2623
2658
  }
2624
- const tt = "BEFORE", rt = "AFTER";
2625
- function vs(r) {
2626
- const { result: t, outputLimit: s } = r;
2627
- if (t.replace == null) {
2628
- const h = fe({
2629
- content: t.search.content,
2630
- matches: t.search.matches,
2659
+ const ot = "BEFORE", nt = "AFTER";
2660
+ function Fs(t) {
2661
+ const { result: r, outputLimit: s } = t;
2662
+ if (r.replace == null) {
2663
+ const m = fe({
2664
+ content: r.search.content,
2665
+ matches: r.search.matches,
2631
2666
  outputLimit: s
2632
2667
  });
2633
- return { output: h.output, truncated: h.truncated };
2668
+ return { output: m.output, truncated: m.truncated };
2634
2669
  }
2635
- const o = `<${tt}>
2636
- `, e = `</${tt}>
2637
- `, n = `<${rt}>
2638
- `, i = `</${rt}>
2670
+ const o = `<${ot}>
2671
+ `, e = `</${ot}>
2672
+ `, n = `<${nt}>
2673
+ `, i = `</${nt}>
2639
2674
  `, a = o.length + e.length + n.length + i.length;
2640
2675
  if (s != null && s < a)
2641
2676
  return { output: "", truncated: !0 };
2642
2677
  const c = s != null ? s - a : void 0, l = c != null ? Math.floor(c / 2) : void 0, u = fe({
2643
- content: t.search.content,
2644
- matches: t.search.matches,
2678
+ content: r.search.content,
2679
+ matches: r.search.matches,
2645
2680
  outputLimit: l
2646
2681
  }), f = c != null ? c - u.output.length : void 0, d = fe({
2647
- content: t.replace.content,
2648
- matches: t.replace.matches,
2682
+ content: r.replace.content,
2683
+ matches: r.replace.matches,
2649
2684
  outputLimit: f
2650
2685
  });
2651
2686
  return { output: o + u.output + e + n + d.output + i, truncated: u.truncated || d.truncated };
2652
2687
  }
2653
- function Ie(r) {
2654
- const { result: t, rootDir: s, errorsOnly: o } = r;
2688
+ function Ie(t) {
2689
+ const { result: r, rootDir: s, errorsOnly: o } = t;
2655
2690
  let e = "";
2656
- for (let n = 0; n < t.results.length; n++) {
2657
- const i = t.results[n], a = k.relative(s, i.filePath), c = e.length > 0 ? 1 : 0;
2691
+ for (let n = 0; n < r.results.length; n++) {
2692
+ const i = r.results[n], a = k.relative(s, i.filePath), c = e.length > 0 ? 1 : 0;
2658
2693
  if (i.error != null) {
2659
2694
  const u = a + `
2660
2695
  ❌ ` + i.error + `
@@ -2665,7 +2700,7 @@ function Ie(r) {
2665
2700
  }
2666
2701
  if (o || i.result == null || i.result.search.matches.length === 0)
2667
2702
  continue;
2668
- const l = vs({
2703
+ const l = Fs({
2669
2704
  result: i.result
2670
2705
  });
2671
2706
  l.output.length > 0 && (c > 0 && (e += `
@@ -2674,25 +2709,25 @@ function Ie(r) {
2674
2709
  }
2675
2710
  return e;
2676
2711
  }
2677
- const Ns = m.object({
2678
- pattern: m.string().describe("JS RegExp pattern"),
2679
- flags: m.string().default("gm").describe('JS RegExp flags. Default: "gm"')
2680
- }), kt = m.object({
2681
- snapshotName: m.string().optional().describe("Name of previously created filesystem snapshot, to use"),
2712
+ const Bs = h.object({
2713
+ pattern: h.string().describe("JS RegExp pattern"),
2714
+ flags: h.string().default("gm").describe('JS RegExp flags. Default: "gm"')
2715
+ }), Ft = h.object({
2716
+ snapshotName: h.string().optional().describe("Name of previously created filesystem snapshot, to use"),
2682
2717
  snapshot: ee.optional().describe(
2683
2718
  "Filesystem snapshot creation options JSON to automatically create snapshot"
2684
2719
  ),
2685
- bulkOperations: m.array(Ns).describe(
2720
+ bulkOperations: h.array(Bs).describe(
2686
2721
  "All search patterns to execute; include every pattern here; never split across multiple calls"
2687
2722
  ),
2688
- outputLimit: m.number().int().min(0).max(J).default(Q).describe(
2723
+ outputLimit: h.number().int().min(0).max(J).default(Q).describe(
2689
2724
  `Maximum output characters. Output exceeding this limit will be truncated. Maximum: ${J}. Default: ${Q}`
2690
2725
  )
2691
2726
  });
2692
- async function ks(r, t, s) {
2727
+ async function Ls(t, r, s) {
2693
2728
  let o;
2694
2729
  try {
2695
- o = kt.parse(r);
2730
+ o = Ft.parse(t);
2696
2731
  } catch (w) {
2697
2732
  return {
2698
2733
  error: F(w)
@@ -2717,7 +2752,7 @@ async function ks(r, t, s) {
2717
2752
  } else if (n) {
2718
2753
  const w = await ce(
2719
2754
  n,
2720
- t,
2755
+ r,
2721
2756
  s
2722
2757
  );
2723
2758
  if (w.error != null)
@@ -2729,11 +2764,11 @@ async function ks(r, t, s) {
2729
2764
  return {
2730
2765
  error: "Either snapshotName or snapshot must be provided"
2731
2766
  };
2732
- const d = vt(l), p = l.query.rootDir ?? ".", h = await $e({
2767
+ const d = Rt(l), p = l.query.rootDir ?? ".", m = await $e({
2733
2768
  filePaths: d,
2734
2769
  operations: i
2735
2770
  }), g = Ie({
2736
- result: h,
2771
+ result: m,
2737
2772
  rootDir: p
2738
2773
  });
2739
2774
  return { output: we({
@@ -2742,18 +2777,18 @@ async function ks(r, t, s) {
2742
2777
  limit: a
2743
2778
  }).content, rootDir: p, fsSnapshot: l, queryCreated: u, snapshotCreated: f };
2744
2779
  }
2745
- function Os(r, t) {
2746
- r(
2780
+ function Ps(t, r) {
2781
+ t(
2747
2782
  "fs-snapshot-search",
2748
2783
  {
2749
2784
  title: "Search File Contents in Snapshot",
2750
2785
  description: "Search file contents using JS RegExp. Use this to find text patterns across snapshot files. Put all search patterns in the bulkOperations array; use one snapshot with rootDir covering all target files; never split into multiple calls based on file locations, directories, or pattern groups",
2751
- inputSchema: kt.shape
2786
+ inputSchema: Ft.shape
2752
2787
  },
2753
2788
  async (s, o) => {
2754
- const e = await ks(
2789
+ const e = await Ls(
2755
2790
  s,
2756
- t,
2791
+ r,
2757
2792
  o
2758
2793
  );
2759
2794
  if (e.error != null)
@@ -2772,26 +2807,26 @@ Reminder: use one snapshot covering all target files; include all patterns in th
2772
2807
  }
2773
2808
  );
2774
2809
  }
2775
- const Ds = m.object({
2776
- pattern: m.string().describe("JS RegExp pattern"),
2777
- flags: m.string().default("gm").describe('JS RegExp flags. Default: "gm"'),
2778
- replacement: m.string().describe("JS replacement pattern")
2779
- }), Ot = m.object({
2780
- snapshotName: m.string().optional().describe("Name of previously created filesystem snapshot, to use"),
2810
+ const As = h.object({
2811
+ pattern: h.string().describe("JS RegExp pattern"),
2812
+ flags: h.string().default("gm").describe('JS RegExp flags. Default: "gm"'),
2813
+ replacement: h.string().describe("JS replacement pattern")
2814
+ }), Bt = h.object({
2815
+ snapshotName: h.string().optional().describe("Name of previously created filesystem snapshot, to use"),
2781
2816
  snapshot: ee.optional().describe(
2782
2817
  "Filesystem snapshot creation options JSON to automatically create snapshot"
2783
2818
  ),
2784
- bulkOperations: m.array(Ds).describe(
2819
+ bulkOperations: h.array(As).describe(
2785
2820
  "All replace patterns to execute; include every pattern here; never split across multiple calls"
2786
2821
  ),
2787
- outputLimit: m.number().int().min(0).max(J).default(Q).describe(
2822
+ outputLimit: h.number().int().min(0).max(J).default(Q).describe(
2788
2823
  `Maximum output characters. Output exceeding this limit will be truncated. Maximum: ${J}. Default: ${Q}`
2789
2824
  )
2790
2825
  });
2791
- async function Rs(r, t, s) {
2826
+ async function zs(t, r, s) {
2792
2827
  let o;
2793
2828
  try {
2794
- o = Ot.parse(r);
2829
+ o = Bt.parse(t);
2795
2830
  } catch (b) {
2796
2831
  return {
2797
2832
  error: F(b)
@@ -2816,7 +2851,7 @@ async function Rs(r, t, s) {
2816
2851
  } else if (n) {
2817
2852
  const b = await ce(
2818
2853
  n,
2819
- t,
2854
+ r,
2820
2855
  s
2821
2856
  );
2822
2857
  if (b.error != null)
@@ -2828,16 +2863,16 @@ async function Rs(r, t, s) {
2828
2863
  return {
2829
2864
  error: "Either snapshotName or snapshot must be provided"
2830
2865
  };
2831
- const d = vt(l), p = l.query.rootDir ?? ".", h = {
2866
+ const d = Rt(l), p = l.query.rootDir ?? ".", m = {
2832
2867
  filePaths: d,
2833
2868
  operations: i
2834
2869
  }, g = Date.now(), y = await $e({
2835
- ...h,
2870
+ ...m,
2836
2871
  dryRun: !0
2837
- }), w = Xr();
2872
+ }), w = ns();
2838
2873
  c.preparedReplace = {
2839
2874
  id: w,
2840
- options: h,
2875
+ options: m,
2841
2876
  rootDir: p,
2842
2877
  dateCreated: g
2843
2878
  };
@@ -2853,18 +2888,18 @@ Review the output carefully before executing. Call fs-snapshot-replace-execute w
2853
2888
  limit: a
2854
2889
  }).content, rootDir: p, fsSnapshot: l, queryCreated: u, snapshotCreated: f };
2855
2890
  }
2856
- function Fs(r, t) {
2857
- r(
2891
+ function Us(t, r) {
2892
+ t(
2858
2893
  "fs-snapshot-replace-prepare",
2859
2894
  {
2860
2895
  title: "Prepare File Content Replacement",
2861
2896
  description: "Prepares text replacement in files using JS RegExp. Use this to perform bulk replacements across snapshot files. Put all replace patterns in the bulkOperations array; use one snapshot with rootDir covering all target files; never split into multiple calls based on file locations, directories, or pattern groups. Read and review full output to the end. If all replacements are valid get replaceId from the end of output and call fs-snapshot-replace-execute to apply it.",
2862
- inputSchema: Ot.shape
2897
+ inputSchema: Bt.shape
2863
2898
  },
2864
2899
  async (s, o) => {
2865
- const e = await Rs(
2900
+ const e = await zs(
2866
2901
  s,
2867
- t,
2902
+ r,
2868
2903
  o
2869
2904
  );
2870
2905
  if (e.error != null)
@@ -2883,13 +2918,13 @@ Reminder: use one snapshot covering all target files; include all patterns in th
2883
2918
  }
2884
2919
  );
2885
2920
  }
2886
- const Dt = m.object({
2887
- replaceId: m.string().describe("Replace ID from the END of fs-snapshot-replace-prepare output. NEVER fabricate or guess this value.")
2921
+ const Lt = h.object({
2922
+ replaceId: h.string().describe("Replace ID from the END of fs-snapshot-replace-prepare output. NEVER fabricate or guess this value.")
2888
2923
  });
2889
- async function Bs(r, t, s) {
2924
+ async function js(t, r, s) {
2890
2925
  let o;
2891
2926
  try {
2892
- o = Dt.parse(r);
2927
+ o = Lt.parse(t);
2893
2928
  } catch (l) {
2894
2929
  return {
2895
2930
  error: F(l)
@@ -2919,18 +2954,18 @@ async function Bs(r, t, s) {
2919
2954
  errorsOnly: !0
2920
2955
  }) || null };
2921
2956
  }
2922
- function Ls(r, t) {
2923
- r(
2957
+ function qs(t, r) {
2958
+ t(
2924
2959
  "fs-snapshot-replace-execute",
2925
2960
  {
2926
2961
  title: "Execute Prepared Replacement",
2927
2962
  description: "Executes prepared replacement. Requires replaceId from the end of fs-snapshot-replace-prepare output.",
2928
- inputSchema: Dt.shape
2963
+ inputSchema: Lt.shape
2929
2964
  },
2930
2965
  async (s, o) => {
2931
- const e = await Bs(
2966
+ const e = await js(
2932
2967
  s,
2933
- t,
2968
+ r,
2934
2969
  o
2935
2970
  );
2936
2971
  if (e.error != null)
@@ -2943,32 +2978,32 @@ ${e.output}`), n;
2943
2978
  }
2944
2979
  );
2945
2980
  }
2946
- function Ps(r, t) {
2947
- t.list && Vr(r, t), t.snapshotQueryCreate && ts(r, t), t.snapshotCreate && cs(r, t), t.snapshotBrowse && hs(r, t), t.snapshotSearch && Os(r, t), t.snapshotReplace && (Fs(r, t), Ls(r, t)), console.log(
2981
+ function _s(t, r) {
2982
+ r.list && ss(t, r), r.snapshotQueryCreate && as(t, r), r.snapshotCreate && ms(t, r), r.snapshotBrowse && Ss(t, r), r.snapshotSearch && Ps(t, r), r.snapshotReplace && (Us(t, r), qs(t, r)), console.log(
2948
2983
  `File manager:
2949
- - Working directory: ${k.resolve(t.workingDir || "")}
2984
+ - Working directory: ${k.resolve(r.workingDir || "")}
2950
2985
  `
2951
2986
  );
2952
2987
  }
2953
2988
  const pe = /* @__PURE__ */ new Map();
2954
- function W(r) {
2955
- return pe.has(r) || pe.set(r, {
2989
+ function W(t) {
2990
+ return pe.has(t) || pe.set(t, {
2956
2991
  browsers: /* @__PURE__ */ new Map(),
2957
2992
  domSnapshotQueries: /* @__PURE__ */ new Map()
2958
- }), pe.get(r);
2993
+ }), pe.get(t);
2959
2994
  }
2960
- const Me = m.object({
2961
- name: m.string().describe(
2995
+ const Me = h.object({
2996
+ name: h.string().describe(
2962
2997
  "Unique name for the browser. Recommended format: kebab-case-1, kebab-case-2, ..."
2963
2998
  ),
2964
- browserType: m.enum(["chromium", "firefox", "webkit"]).describe("Browser type to launch"),
2965
- muteAudio: m.boolean().optional().describe("Mute audio in the browser"),
2966
- devTools: m.boolean().optional().describe("Open browser with dev tools")
2999
+ browserType: h.enum(["chromium", "firefox", "webkit"]).describe("Browser type to launch"),
3000
+ muteAudio: h.boolean().optional().describe("Mute audio in the browser"),
3001
+ devTools: h.boolean().optional().describe("Open browser with dev tools")
2967
3002
  });
2968
- async function Rt(r, t, s) {
3003
+ async function Pt(t, r, s) {
2969
3004
  let o;
2970
3005
  try {
2971
- o = Me.parse(r);
3006
+ o = Me.parse(t);
2972
3007
  } catch (l) {
2973
3008
  return {
2974
3009
  error: F(l)
@@ -2982,9 +3017,9 @@ async function Rt(r, t, s) {
2982
3017
  const c = W(s.sessionId);
2983
3018
  try {
2984
3019
  const u = await {
2985
- chromium: nr,
2986
- firefox: or,
2987
- webkit: sr
3020
+ chromium: cr,
3021
+ firefox: lr,
3022
+ webkit: ar
2988
3023
  }[n].launch({
2989
3024
  headless: !1,
2990
3025
  devtools: a,
@@ -3002,8 +3037,8 @@ async function Rt(r, t, s) {
3002
3037
  };
3003
3038
  }
3004
3039
  }
3005
- function As(r, t) {
3006
- r(
3040
+ function Gs(t, r) {
3041
+ t(
3007
3042
  "playwright-browser-create",
3008
3043
  {
3009
3044
  title: "Create Browser",
@@ -3011,17 +3046,17 @@ function As(r, t) {
3011
3046
  inputSchema: Me.shape
3012
3047
  },
3013
3048
  async (s, o) => {
3014
- const e = await Rt(s, t, o);
3049
+ const e = await Pt(s, r, o);
3015
3050
  return `Method: playwright-browser-create(${JSON.stringify(s)})
3016
3051
  ${e.error != null ? `❌ Error: ${e.error}` : `✅ Browser "${e.browserInfo.name}" (${e.browserInfo.browserType}) created successfully`}`;
3017
3052
  }
3018
3053
  );
3019
3054
  }
3020
- const Ft = m.object({});
3021
- async function zs(r, t, s) {
3055
+ const At = h.object({});
3056
+ async function Js(t, r, s) {
3022
3057
  let o;
3023
3058
  try {
3024
- o = Ft.parse(r);
3059
+ o = At.parse(t);
3025
3060
  } catch (i) {
3026
3061
  return {
3027
3062
  error: F(i)
@@ -3036,16 +3071,16 @@ async function zs(r, t, s) {
3036
3071
  browserInfos: Array.from(e.browsers.values())
3037
3072
  };
3038
3073
  }
3039
- function Us(r, t) {
3040
- r(
3074
+ function Ws(t, r) {
3075
+ t(
3041
3076
  "playwright-browser-list",
3042
3077
  {
3043
3078
  title: "List Browsers",
3044
3079
  description: "List active browser instances",
3045
- inputSchema: Ft.shape
3080
+ inputSchema: At.shape
3046
3081
  },
3047
3082
  async (s, o) => {
3048
- const e = await zs(s, t, o);
3083
+ const e = await Js(s, r, o);
3049
3084
  if (e.error != null)
3050
3085
  return `Method: playwright-browser-list(${JSON.stringify(s)})
3051
3086
  ❌ Error: ${e.error}`;
@@ -3057,15 +3092,15 @@ ${n.length === 0 ? "No browsers found" : `Browsers: ${n.join(", ")}`}`;
3057
3092
  }
3058
3093
  );
3059
3094
  }
3060
- const Bt = m.object({
3061
- names: m.array(m.string()).optional().describe(
3095
+ const zt = h.object({
3096
+ names: h.array(h.string()).optional().describe(
3062
3097
  "Names of browsers to close. If not specified, closes all browsers"
3063
3098
  )
3064
3099
  });
3065
- async function js(r, t, s) {
3100
+ async function Ks(t, r, s) {
3066
3101
  let o;
3067
3102
  try {
3068
- o = Bt.parse(r);
3103
+ o = zt.parse(t);
3069
3104
  } catch (l) {
3070
3105
  return {
3071
3106
  error: F(l)
@@ -3096,16 +3131,16 @@ async function js(r, t, s) {
3096
3131
  ...a.length > 0 && { errors: a }
3097
3132
  };
3098
3133
  }
3099
- function qs(r, t) {
3100
- r(
3134
+ function Hs(t, r) {
3135
+ t(
3101
3136
  "playwright-browser-close",
3102
3137
  {
3103
3138
  title: "Close Browsers",
3104
3139
  description: "Close browsers. Automatically closes all contexts and pages within the browsers",
3105
- inputSchema: Bt.shape
3140
+ inputSchema: zt.shape
3106
3141
  },
3107
3142
  async (s, o) => {
3108
- const e = await js(s, t, o);
3143
+ const e = await Ks(s, r, o);
3109
3144
  if (e.error != null)
3110
3145
  return `Method: playwright-browser-close(${JSON.stringify(s)})
3111
3146
  ❌ Error: ${e.error}`;
@@ -3122,25 +3157,25 @@ ${n.join(`
3122
3157
  }
3123
3158
  );
3124
3159
  }
3125
- const Te = m.object({
3126
- browserName: m.string().optional().describe("Name of previously created browser, to use"),
3160
+ const Te = h.object({
3161
+ browserName: h.string().optional().describe("Name of previously created browser, to use"),
3127
3162
  browser: Me.optional().describe(
3128
3163
  "Browser creation options JSON to automatically create browser"
3129
3164
  ),
3130
- name: m.string().describe(
3165
+ name: h.string().describe(
3131
3166
  "Unique name for the context. Recommended format: kebab-case-1, kebab-case-2, ..."
3132
3167
  ),
3133
- isMobile: m.boolean().optional().describe("Configure for mobile device simulation"),
3134
- hasTouch: m.boolean().optional().describe("Enable touch events"),
3135
- viewport: m.object({
3136
- width: m.number(),
3137
- height: m.number()
3168
+ isMobile: h.boolean().optional().describe("Configure for mobile device simulation"),
3169
+ hasTouch: h.boolean().optional().describe("Enable touch events"),
3170
+ viewport: h.object({
3171
+ width: h.number(),
3172
+ height: h.number()
3138
3173
  }).optional().describe("Viewport size configuration")
3139
3174
  });
3140
- async function Lt(r, t, s) {
3175
+ async function Ut(t, r, s) {
3141
3176
  let o;
3142
3177
  try {
3143
- o = Te.parse(r);
3178
+ o = Te.parse(t);
3144
3179
  } catch (p) {
3145
3180
  return {
3146
3181
  error: F(p)
@@ -3163,7 +3198,7 @@ async function Lt(r, t, s) {
3163
3198
  error: `Browser "${n}" not found`
3164
3199
  };
3165
3200
  } else if (i) {
3166
- const p = await Rt(i, t, s);
3201
+ const p = await Pt(i, r, s);
3167
3202
  if (p.error != null)
3168
3203
  return {
3169
3204
  error: p.error
@@ -3178,16 +3213,16 @@ async function Lt(r, t, s) {
3178
3213
  isMobile: a,
3179
3214
  hasTouch: c,
3180
3215
  viewport: l
3181
- }), h = {
3216
+ }), m = {
3182
3217
  browserInfo: d,
3183
3218
  name: e,
3184
3219
  context: p,
3185
3220
  pages: /* @__PURE__ */ new Map()
3186
3221
  };
3187
- return d.contexts.set(e, h), {
3222
+ return d.contexts.set(e, m), {
3188
3223
  browserInfoCreated: f,
3189
3224
  browserInfo: d,
3190
- contextInfo: h
3225
+ contextInfo: m
3191
3226
  };
3192
3227
  } catch (p) {
3193
3228
  return {
@@ -3195,8 +3230,8 @@ async function Lt(r, t, s) {
3195
3230
  };
3196
3231
  }
3197
3232
  }
3198
- function Gs(r, t) {
3199
- r(
3233
+ function Qs(t, r) {
3234
+ t(
3200
3235
  "playwright-context-create",
3201
3236
  {
3202
3237
  title: "Create Browser Context",
@@ -3204,7 +3239,7 @@ function Gs(r, t) {
3204
3239
  inputSchema: Te.shape
3205
3240
  },
3206
3241
  async (s, o) => {
3207
- const e = await Lt(s, t, o);
3242
+ const e = await Ut(s, r, o);
3208
3243
  if (e.error != null)
3209
3244
  return `Method: playwright-context-create(${JSON.stringify(s)})
3210
3245
  ❌ Error: ${e.error}`;
@@ -3215,15 +3250,15 @@ function Gs(r, t) {
3215
3250
  }
3216
3251
  );
3217
3252
  }
3218
- const Pt = m.object({
3219
- browserName: m.string().optional().describe(
3253
+ const jt = h.object({
3254
+ browserName: h.string().optional().describe(
3220
3255
  "Name of browser to list contexts from. If not specified, lists contexts from all browsers"
3221
3256
  )
3222
3257
  });
3223
- async function _s(r, t, s) {
3258
+ async function Ys(t, r, s) {
3224
3259
  let o;
3225
3260
  try {
3226
- o = Pt.parse(r);
3261
+ o = jt.parse(t);
3227
3262
  } catch (a) {
3228
3263
  return {
3229
3264
  error: F(a)
@@ -3257,16 +3292,16 @@ async function _s(r, t, s) {
3257
3292
  contextsByBrowser: i
3258
3293
  };
3259
3294
  }
3260
- function Js(r, t) {
3261
- r(
3295
+ function Vs(t, r) {
3296
+ t(
3262
3297
  "playwright-context-list",
3263
3298
  {
3264
3299
  title: "List Browser Contexts",
3265
3300
  description: "List active browser contexts",
3266
- inputSchema: Pt.shape
3301
+ inputSchema: jt.shape
3267
3302
  },
3268
3303
  async (s, o) => {
3269
- const e = await _s(s, t, o);
3304
+ const e = await Ys(s, r, o);
3270
3305
  if ("error" in e)
3271
3306
  return `Method: playwright-context-list(${JSON.stringify(s)})
3272
3307
  ❌ Error: ${e.error}`;
@@ -3279,18 +3314,18 @@ function Js(r, t) {
3279
3314
  }
3280
3315
  );
3281
3316
  }
3282
- const At = m.object({
3283
- names: m.array(m.string()).optional().describe(
3317
+ const qt = h.object({
3318
+ names: h.array(h.string()).optional().describe(
3284
3319
  "Names of contexts to close. If not specified, closes all contexts"
3285
3320
  ),
3286
- browserName: m.string().optional().describe(
3321
+ browserName: h.string().optional().describe(
3287
3322
  "Name of browser to close contexts from. If not specified, searches all browsers"
3288
3323
  )
3289
3324
  });
3290
- async function Ws(r, t, s) {
3325
+ async function Zs(t, r, s) {
3291
3326
  let o;
3292
3327
  try {
3293
- o = At.parse(r);
3328
+ o = qt.parse(t);
3294
3329
  } catch (u) {
3295
3330
  return {
3296
3331
  error: F(u)
@@ -3341,16 +3376,16 @@ async function Ws(r, t, s) {
3341
3376
  ...c.length > 0 && { errors: c }
3342
3377
  };
3343
3378
  }
3344
- function Ks(r, t) {
3345
- r(
3379
+ function Xs(t, r) {
3380
+ t(
3346
3381
  "playwright-context-close",
3347
3382
  {
3348
3383
  title: "Close Browser Contexts",
3349
3384
  description: "Close browser contexts. Automatically closes all pages within the contexts",
3350
- inputSchema: At.shape
3385
+ inputSchema: qt.shape
3351
3386
  },
3352
3387
  async (s, o) => {
3353
- const e = await Ws(s, t, o);
3388
+ const e = await Zs(s, r, o);
3354
3389
  if ("error" in e)
3355
3390
  return `Method: playwright-context-close(${JSON.stringify(s)})
3356
3391
  ❌ Error: ${e.error}`;
@@ -3367,8 +3402,8 @@ ${n.join(`
3367
3402
  }
3368
3403
  );
3369
3404
  }
3370
- function Hs() {
3371
- class r {
3405
+ function eo() {
3406
+ class t {
3372
3407
  prevId = 0;
3373
3408
  objectToId = /* @__PURE__ */ new WeakMap();
3374
3409
  idToObject = /* @__PURE__ */ new Map();
@@ -3390,60 +3425,60 @@ function Hs() {
3390
3425
  return u ?? (this.idToObject.delete(c), null);
3391
3426
  }
3392
3427
  }
3393
- function t(a, c, l) {
3428
+ function r(a, c, l) {
3394
3429
  let u = null;
3395
3430
  for (let f = 0, d = c.length; f < d; f++) {
3396
- const p = c[f], h = a(p), g = h == null ? null : t(a, h, l), y = l(p, g);
3431
+ const p = c[f], m = a(p), g = m == null ? null : r(a, m, l), y = l(p, g);
3397
3432
  y != null && (u == null && (u = []), u.push(y));
3398
3433
  }
3399
3434
  return u;
3400
3435
  }
3401
3436
  function s(a) {
3402
- const { getId: c, getChilds: l, rootNodes: u, createSnapshotNode: f } = a, d = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), g = t(
3437
+ const { getId: c, getChilds: l, rootNodes: u, createSnapshotNode: f } = a, d = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), g = r(
3403
3438
  l,
3404
3439
  u,
3405
3440
  (w, M) => {
3406
- const v = f(w, M);
3407
- if (w != null && v != null) {
3441
+ const E = f(w, M);
3442
+ if (w != null && E != null) {
3408
3443
  const b = c(w);
3409
- d.set(b, v), p.set(v, b);
3444
+ d.set(b, E), p.set(E, b);
3410
3445
  }
3411
- return v != null && M != null && h.set(
3412
- p.get(v),
3446
+ return E != null && M != null && m.set(
3447
+ p.get(E),
3413
3448
  M.map((b) => p.get(b))
3414
- ), v;
3449
+ ), E;
3415
3450
  }
3416
3451
  ), y = f(null, g);
3417
3452
  if (y == null)
3418
3453
  throw new Error("Impossible behavior: rootNode == null");
3419
- return d.set(null, y), g != null && h.set(
3454
+ return d.set(null, y), g != null && m.set(
3420
3455
  null,
3421
3456
  g.map((w) => p.get(w))
3422
3457
  ), {
3423
3458
  idToNode: d,
3424
- idToChildIds: h
3459
+ idToChildIds: m
3425
3460
  };
3426
3461
  }
3427
3462
  const o = (a) => a instanceof HTMLElement ? a.childNodes : null;
3428
3463
  function e(a) {
3429
3464
  return function(l, u) {
3430
3465
  const f = u != null && u.length > 0;
3431
- let d = !1, p = null, h = null;
3466
+ let d = !1, p = null, m = null;
3432
3467
  if (l instanceof HTMLElement) {
3433
- if (p = n.getOrCreateId(l), h = l.tagName.toLowerCase(), d = l.matches(a.cssSelector), !d && !f)
3468
+ if (p = n.getOrCreateId(l), m = l.tagName.toLowerCase(), d = l.matches(a.cssSelector), !d && !f)
3434
3469
  return null;
3435
3470
  } else if (l == null)
3436
- p = null, h = null, d = !1;
3471
+ p = null, m = null, d = !1;
3437
3472
  else
3438
3473
  return null;
3439
3474
  return {
3440
3475
  uid: p,
3441
- tagName: h,
3476
+ tagName: m,
3442
3477
  isMatched: d
3443
3478
  };
3444
3479
  };
3445
3480
  }
3446
- const n = new r();
3481
+ const n = new t();
3447
3482
  function i(a) {
3448
3483
  const c = e(a);
3449
3484
  return s({
@@ -3455,19 +3490,19 @@ function Hs() {
3455
3490
  }
3456
3491
  window.__mcp_playwright_tool_tx4byhar35_createDomSnapshotTreeRawDom = i;
3457
3492
  }
3458
- const Qs = `(function (){function __name(fn){return fn};${Hs.toString()}; setupPageGlobals();})()`, Ce = m.object({
3459
- contextName: m.string().optional().describe("Name of previously created context, to use"),
3493
+ const to = `(function (){function __name(fn){return fn};${eo.toString()}; setupPageGlobals();})()`, Ce = h.object({
3494
+ contextName: h.string().optional().describe("Name of previously created context, to use"),
3460
3495
  context: Te.optional().describe(
3461
3496
  "Context creation options JSON to automatically create context"
3462
3497
  ),
3463
- name: m.string().describe(
3498
+ name: h.string().describe(
3464
3499
  "Unique name for the page. Recommended format: kebab-case-1, kebab-case-2, ..."
3465
3500
  )
3466
3501
  });
3467
- async function zt(r, t, s) {
3502
+ async function _t(t, r, s) {
3468
3503
  let o;
3469
3504
  try {
3470
- o = Ce.parse(r);
3505
+ o = Ce.parse(t);
3471
3506
  } catch (f) {
3472
3507
  return {
3473
3508
  error: F(f)
@@ -3495,7 +3530,7 @@ async function zt(r, t, s) {
3495
3530
  error: `Context "${n}" not found`
3496
3531
  };
3497
3532
  } else if (i) {
3498
- const f = await Lt(i, t, s);
3533
+ const f = await Ut(i, r, s);
3499
3534
  if (f.error != null)
3500
3535
  return {
3501
3536
  error: f.error
@@ -3507,7 +3542,7 @@ async function zt(r, t, s) {
3507
3542
  };
3508
3543
  try {
3509
3544
  const f = await u.context.newPage();
3510
- await f.addInitScript(Qs), await f.goto("about:blank");
3545
+ await f.addInitScript(to), await f.goto("about:blank");
3511
3546
  const d = {
3512
3547
  contextInfo: u,
3513
3548
  name: e,
@@ -3525,8 +3560,8 @@ async function zt(r, t, s) {
3525
3560
  };
3526
3561
  }
3527
3562
  }
3528
- function Ys(r, t) {
3529
- r(
3563
+ function ro(t, r) {
3564
+ t(
3530
3565
  "playwright-page-create",
3531
3566
  {
3532
3567
  title: "Create Page",
@@ -3534,7 +3569,7 @@ function Ys(r, t) {
3534
3569
  inputSchema: Ce.shape
3535
3570
  },
3536
3571
  async (s, o) => {
3537
- const e = await zt(s, t, o);
3572
+ const e = await _t(s, r, o);
3538
3573
  if (e.error != null)
3539
3574
  return `Method: playwright-page-create(${JSON.stringify(s)})
3540
3575
  ❌ Error: ${e.error}`;
@@ -3546,18 +3581,18 @@ function Ys(r, t) {
3546
3581
  }
3547
3582
  );
3548
3583
  }
3549
- const Ut = m.object({
3550
- contextName: m.string().optional().describe(
3584
+ const Gt = h.object({
3585
+ contextName: h.string().optional().describe(
3551
3586
  "Name of context to list pages from. If not specified, lists pages from all contexts"
3552
3587
  ),
3553
- browserName: m.string().optional().describe(
3588
+ browserName: h.string().optional().describe(
3554
3589
  "Name of browser to search in. If not specified, searches all browsers"
3555
3590
  )
3556
3591
  });
3557
- async function Vs(r, t, s) {
3592
+ async function so(t, r, s) {
3558
3593
  let o;
3559
3594
  try {
3560
- o = Ut.parse(r);
3595
+ o = Gt.parse(t);
3561
3596
  } catch (c) {
3562
3597
  return {
3563
3598
  error: F(c)
@@ -3618,16 +3653,16 @@ async function Vs(r, t, s) {
3618
3653
  pagesByContext: a
3619
3654
  };
3620
3655
  }
3621
- function Zs(r, t) {
3622
- r(
3656
+ function oo(t, r) {
3657
+ t(
3623
3658
  "playwright-page-list",
3624
3659
  {
3625
3660
  title: "List Pages",
3626
3661
  description: "List active pages",
3627
- inputSchema: Ut.shape
3662
+ inputSchema: Gt.shape
3628
3663
  },
3629
3664
  async (s, o) => {
3630
- const e = await Vs(s, t, o);
3665
+ const e = await so(s, r, o);
3631
3666
  if ("error" in e)
3632
3667
  return `Method: playwright-page-list(${JSON.stringify(s)})
3633
3668
  ❌ Error: ${e.error}`;
@@ -3640,19 +3675,19 @@ function Zs(r, t) {
3640
3675
  }
3641
3676
  );
3642
3677
  }
3643
- const jt = m.object({
3644
- names: m.array(m.string()).optional().describe("Names of pages to close. If not specified, closes all pages"),
3645
- contextName: m.string().optional().describe(
3678
+ const Jt = h.object({
3679
+ names: h.array(h.string()).optional().describe("Names of pages to close. If not specified, closes all pages"),
3680
+ contextName: h.string().optional().describe(
3646
3681
  "Name of context to close pages from. If not specified, searches all contexts"
3647
3682
  ),
3648
- browserName: m.string().optional().describe(
3683
+ browserName: h.string().optional().describe(
3649
3684
  "Name of browser to search in. If not specified, searches all browsers"
3650
3685
  )
3651
3686
  });
3652
- async function Xs(r, t, s) {
3687
+ async function no(t, r, s) {
3653
3688
  let o;
3654
3689
  try {
3655
- o = jt.parse(r);
3690
+ o = Jt.parse(t);
3656
3691
  } catch (f) {
3657
3692
  return {
3658
3693
  error: F(f)
@@ -3678,16 +3713,16 @@ async function Xs(r, t, s) {
3678
3713
  error: `Context "${n}" not found in browser "${f.name}" (${f.browserType})`
3679
3714
  };
3680
3715
  e ? e.forEach((p) => {
3681
- const h = d.pages.get(p);
3682
- h ? u.push(h) : l.push(
3716
+ const m = d.pages.get(p);
3717
+ m ? u.push(m) : l.push(
3683
3718
  `Page "${p}" not found in context "${d.name}" in browser "${f.name}" (${f.browserType})`
3684
3719
  );
3685
3720
  }) : u = Array.from(d.pages.values());
3686
3721
  } else
3687
3722
  for (const d of f.contexts.values())
3688
3723
  e ? e.forEach((p) => {
3689
- const h = d.pages.get(p);
3690
- h ? u.push(h) : l.push(
3724
+ const m = d.pages.get(p);
3725
+ m ? u.push(m) : l.push(
3691
3726
  `Page "${p}" not found in context "${d.name}" in browser "${f.name}" (${f.browserType})`
3692
3727
  );
3693
3728
  }) : u.push(...Array.from(d.pages.values()));
@@ -3695,8 +3730,8 @@ async function Xs(r, t, s) {
3695
3730
  for (const f of a.browsers.values()) {
3696
3731
  const d = f.contexts.get(n);
3697
3732
  d && (e ? e.forEach((p) => {
3698
- const h = d.pages.get(p);
3699
- h ? u.push(h) : l.push(
3733
+ const m = d.pages.get(p);
3734
+ m ? u.push(m) : l.push(
3700
3735
  `Page "${p}" not found in context "${d.name}" in browser "${f.name}" (${f.browserType})`
3701
3736
  );
3702
3737
  }) : u.push(...Array.from(d.pages.values())));
@@ -3705,8 +3740,8 @@ async function Xs(r, t, s) {
3705
3740
  for (const f of a.browsers.values())
3706
3741
  for (const d of f.contexts.values())
3707
3742
  e ? e.forEach((p) => {
3708
- const h = d.pages.get(p);
3709
- h ? u.push(h) : l.push(
3743
+ const m = d.pages.get(p);
3744
+ m ? u.push(m) : l.push(
3710
3745
  `Page "${p}" not found in context "${d.name}" in browser "${f.name}" (${f.browserType})`
3711
3746
  );
3712
3747
  }) : u.push(...Array.from(d.pages.values()));
@@ -3727,16 +3762,16 @@ async function Xs(r, t, s) {
3727
3762
  ...l.length > 0 && { errors: l }
3728
3763
  };
3729
3764
  }
3730
- function eo(r, t) {
3731
- r(
3765
+ function io(t, r) {
3766
+ t(
3732
3767
  "playwright-page-close",
3733
3768
  {
3734
3769
  title: "Close Pages",
3735
3770
  description: "Close pages",
3736
- inputSchema: jt.shape
3771
+ inputSchema: Jt.shape
3737
3772
  },
3738
3773
  async (s, o) => {
3739
- const e = await Xs(s, t, o);
3774
+ const e = await no(s, r, o);
3740
3775
  if ("error" in e)
3741
3776
  return `Method: playwright-page-close(${JSON.stringify(s)})
3742
3777
  ❌ Error: ${e.error}`;
@@ -3747,14 +3782,14 @@ ${n.join(`
3747
3782
  }
3748
3783
  );
3749
3784
  }
3750
- const qt = m.object({
3751
- pageName: m.string().optional().describe("Name of previously created page to navigate"),
3785
+ const Wt = h.object({
3786
+ pageName: h.string().optional().describe("Name of previously created page to navigate"),
3752
3787
  page: Ce.optional().describe(
3753
3788
  "Page creation options JSON to automatically create page"
3754
3789
  ),
3755
- url: m.string().describe("URL to navigate to"),
3756
- timeout: m.number().describe("Timeout in seconds"),
3757
- waitUntil: m.enum(["load", "domcontentloaded", "networkidle", "commit"]).describe(
3790
+ url: h.string().describe("URL to navigate to"),
3791
+ timeout: h.number().describe("Timeout in seconds"),
3792
+ waitUntil: h.enum(["load", "domcontentloaded", "networkidle", "commit"]).describe(
3758
3793
  `Wait until event:
3759
3794
  - 'domcontentloaded': DOMContentLoaded event is fired
3760
3795
  - 'load': load event is fired
@@ -3762,13 +3797,13 @@ const qt = m.object({
3762
3797
  - 'commit': network response received and document started loading`
3763
3798
  )
3764
3799
  });
3765
- async function to(r, t, s) {
3800
+ async function ao(t, r, s) {
3766
3801
  let o;
3767
3802
  try {
3768
- o = qt.parse(r);
3769
- } catch (h) {
3803
+ o = Wt.parse(t);
3804
+ } catch (m) {
3770
3805
  return {
3771
- error: F(h)
3806
+ error: F(m)
3772
3807
  };
3773
3808
  }
3774
3809
  const { pageName: e, page: n, url: i, timeout: a, waitUntil: c } = o;
@@ -3783,8 +3818,8 @@ async function to(r, t, s) {
3783
3818
  };
3784
3819
  let u = !1, f = !1, d = !1, p;
3785
3820
  if (e) {
3786
- for (const h of l.browsers.values()) {
3787
- for (const g of h.contexts.values())
3821
+ for (const m of l.browsers.values()) {
3822
+ for (const g of m.contexts.values())
3788
3823
  if (g.pages.has(e)) {
3789
3824
  p = g.pages.get(e);
3790
3825
  break;
@@ -3796,27 +3831,27 @@ async function to(r, t, s) {
3796
3831
  error: `Page "${e}" not found`
3797
3832
  };
3798
3833
  } else if (n) {
3799
- const h = await zt(n, t, s);
3800
- if (h.error != null)
3834
+ const m = await _t(n, r, s);
3835
+ if (m.error != null)
3801
3836
  return {
3802
- error: h.error
3837
+ error: m.error
3803
3838
  };
3804
- p = h.pageInfo, u = h.browserInfoCreated, f = h.contextInfoCreated, d = !0;
3839
+ p = m.pageInfo, u = m.browserInfoCreated, f = m.contextInfoCreated, d = !0;
3805
3840
  } else
3806
3841
  return {
3807
3842
  error: "Either pageName or page must be provided"
3808
3843
  };
3809
3844
  try {
3810
- const h = await p.page.goto(i, {
3845
+ const m = await p.page.goto(i, {
3811
3846
  timeout: a * 1e3,
3812
3847
  waitUntil: c
3813
3848
  });
3814
- return h ? {
3849
+ return m ? {
3815
3850
  browserInfoCreated: u,
3816
3851
  contextInfoCreated: f,
3817
3852
  pageInfoCreated: d,
3818
3853
  pageInfo: p,
3819
- status: h.status()
3854
+ status: m.status()
3820
3855
  } : {
3821
3856
  browserInfoCreated: u,
3822
3857
  contextInfoCreated: f,
@@ -3824,22 +3859,22 @@ async function to(r, t, s) {
3824
3859
  pageInfo: p,
3825
3860
  status: 200
3826
3861
  };
3827
- } catch (h) {
3862
+ } catch (m) {
3828
3863
  return {
3829
- error: `Failed to navigate to "${i}": ${h instanceof Error ? h.message : "Unknown error"}`
3864
+ error: `Failed to navigate to "${i}": ${m instanceof Error ? m.message : "Unknown error"}`
3830
3865
  };
3831
3866
  }
3832
3867
  }
3833
- function ro(r, t) {
3834
- r(
3868
+ function lo(t, r) {
3869
+ t(
3835
3870
  "playwright-page-goto",
3836
3871
  {
3837
3872
  title: "Navigate Page",
3838
3873
  description: "Navigate page to URL. Use for manual browser interaction",
3839
- inputSchema: qt.shape
3874
+ inputSchema: Wt.shape
3840
3875
  },
3841
3876
  async (s, o) => {
3842
- const e = await to(s, t, o);
3877
+ const e = await ao(s, r, o);
3843
3878
  if (e.error != null)
3844
3879
  return `Method: playwright-page-goto(${JSON.stringify(s)})
3845
3880
  ❌ Error: ${e.error}`;
@@ -3852,16 +3887,16 @@ function ro(r, t) {
3852
3887
  }
3853
3888
  );
3854
3889
  }
3855
- const Ee = m.object({
3856
- name: m.string().describe(
3890
+ const ve = h.object({
3891
+ name: h.string().describe(
3857
3892
  "Unique name for the DOM snapshot query. Recommended format: kebab-case-1, kebab-case-2, ..."
3858
3893
  ),
3859
- cssSelector: m.string().describe("CSS selector to capture page content")
3894
+ cssSelector: h.string().describe("CSS selector to capture page content")
3860
3895
  });
3861
- async function Gt(r, t, s) {
3896
+ async function Kt(t, r, s) {
3862
3897
  let o;
3863
3898
  try {
3864
- o = Ee.parse(r);
3899
+ o = ve.parse(t);
3865
3900
  } catch (c) {
3866
3901
  return {
3867
3902
  error: F(c)
@@ -3880,30 +3915,30 @@ async function Gt(r, t, s) {
3880
3915
  snapshotQuery: a
3881
3916
  };
3882
3917
  }
3883
- function so(r, t) {
3884
- r(
3918
+ function co(t, r) {
3919
+ t(
3885
3920
  "playwright-dom-snapshot-query-create",
3886
3921
  {
3887
3922
  title: "Create DOM Snapshot Query",
3888
3923
  description: "Create a DOM snapshot query. Prefer dom-snapshot-browse if you need to immediately create a query and snapshot and browse it",
3889
- inputSchema: Ee.shape
3924
+ inputSchema: ve.shape
3890
3925
  },
3891
3926
  async (s, o) => {
3892
- const e = await Gt(s, t, o);
3927
+ const e = await Kt(s, r, o);
3893
3928
  return e.error != null ? `Method: playwright-dom-snapshot-query-create(${JSON.stringify(s)})
3894
3929
  ❌ Error: ${e.error}` : `Method: playwright-dom-snapshot-query-create(${JSON.stringify(s)})
3895
3930
  ✅ DOM snapshot query "${e.snapshotQuery.name}" created successfully`;
3896
3931
  }
3897
3932
  );
3898
3933
  }
3899
- function oo(r) {
3934
+ function uo(t) {
3900
3935
  return function(s, o) {
3901
3936
  let e, n = 0;
3902
3937
  const i = o ? o.length : 0;
3903
3938
  let a = 1, c = 0, l = 0, u, f;
3904
3939
  if (o)
3905
- for (let h = 0; h < o.length; h++) {
3906
- const g = o[h];
3940
+ for (let m = 0; m < o.length; m++) {
3941
+ const g = o[m];
3907
3942
  n += g.countMatched, a += g.countTotal, c += g.tokens, l += g.tokensTotal;
3908
3943
  }
3909
3944
  s ? (u = s.uid, f = s.tagName, e = s.isMatched, e && (n += 1)) : (u = null, f = null, e = !1);
@@ -3917,7 +3952,7 @@ function oo(r) {
3917
3952
  textOpen: `<root uid:${u}>`,
3918
3953
  textClose: "</root>"
3919
3954
  };
3920
- const p = Mt(d);
3955
+ const p = Et(d);
3921
3956
  return l += p, {
3922
3957
  uid: u,
3923
3958
  tagName: f,
@@ -3932,8 +3967,8 @@ function oo(r) {
3932
3967
  };
3933
3968
  };
3934
3969
  }
3935
- function no(r, t) {
3936
- const s = le(t), o = s.getChilds(s.root), e = It({
3970
+ function fo(t, r) {
3971
+ const s = le(r), o = s.getChilds(s.root), e = vt({
3937
3972
  getId: (n) => {
3938
3973
  const i = s.getId(n);
3939
3974
  if (i == null)
@@ -3943,25 +3978,25 @@ function no(r, t) {
3943
3978
  return i;
3944
3979
  },
3945
3980
  getChilds: (n) => s.getChilds(n),
3946
- createSnapshotNode: oo(),
3981
+ createSnapshotNode: uo(),
3947
3982
  rootNodes: o ?? []
3948
3983
  });
3949
3984
  return le(e);
3950
3985
  }
3951
- const ve = m.object({
3952
- pageName: m.string().describe("Name of previously created page, to create snapshot from"),
3953
- queryName: m.string().optional().describe("Name of previously created DOM snapshot query, to use"),
3954
- query: Ee.optional().describe(
3986
+ const Ee = h.object({
3987
+ pageName: h.string().describe("Name of previously created page, to create snapshot from"),
3988
+ queryName: h.string().optional().describe("Name of previously created DOM snapshot query, to use"),
3989
+ query: ve.optional().describe(
3955
3990
  "DOM snapshot query creation options JSON to automatically create query"
3956
3991
  ),
3957
- name: m.string().describe(
3992
+ name: h.string().describe(
3958
3993
  "Unique name for the DOM snapshot. Recommended format: kebab-case-1, kebab-case-2, ..."
3959
3994
  )
3960
3995
  });
3961
- async function _t(r, t, s) {
3996
+ async function Ht(t, r, s) {
3962
3997
  let o;
3963
3998
  try {
3964
- o = ve.parse(r);
3999
+ o = Ee.parse(t);
3965
4000
  } catch (d) {
3966
4001
  return {
3967
4002
  error: F(d)
@@ -3999,9 +4034,9 @@ async function _t(r, t, s) {
3999
4034
  };
4000
4035
  u = d;
4001
4036
  } else if (i) {
4002
- const d = await Gt(
4037
+ const d = await Kt(
4003
4038
  i,
4004
- t,
4039
+ r,
4005
4040
  s
4006
4041
  );
4007
4042
  if (d.error != null)
@@ -4029,10 +4064,10 @@ async function _t(r, t, s) {
4029
4064
  ), p = {
4030
4065
  idToNode: new Map(d.idToNode),
4031
4066
  idToChildIds: new Map(d.idToChildIds)
4032
- }, h = no(u, p), g = {
4067
+ }, m = fo(u, p), g = {
4033
4068
  name: a,
4034
4069
  query: u,
4035
- tree: h
4070
+ tree: m
4036
4071
  };
4037
4072
  return l.domSnapshots.set(a, g), {
4038
4073
  domSnapshot: g,
@@ -4044,16 +4079,16 @@ async function _t(r, t, s) {
4044
4079
  };
4045
4080
  }
4046
4081
  }
4047
- function io(r, t) {
4048
- r(
4082
+ function po(t, r) {
4083
+ t(
4049
4084
  "playwright-dom-snapshot-create",
4050
4085
  {
4051
4086
  title: "Create DOM Snapshot",
4052
4087
  description: "Create a DOM snapshot of page. Use this to capture webpage state for later browsing. Prefer dom-snapshot-browse if you need to immediately create and browse a snapshot",
4053
- inputSchema: ve.shape
4088
+ inputSchema: Ee.shape
4054
4089
  },
4055
4090
  async (s, o) => {
4056
- const e = await _t(s, t, o);
4091
+ const e = await Ht(s, r, o);
4057
4092
  if (e.error != null)
4058
4093
  return `Method: playwright-dom-snapshot-create(${JSON.stringify(s)})
4059
4094
  ❌ Error: ${e.error}`;
@@ -4064,27 +4099,27 @@ function io(r, t) {
4064
4099
  }
4065
4100
  );
4066
4101
  }
4067
- class ao {
4102
+ class ho {
4068
4103
  tokens = 20;
4069
- getReportText = (t) => ({
4104
+ getReportText = (r) => ({
4070
4105
  indent: !0,
4071
- textOpen: `[${t.indexRange[0]}-${t.indexRange[1]}] see more ${t.countMatched} matched ${t.tokensGrouped} tokens`,
4106
+ textOpen: `[${r.indexRange[0]}-${r.indexRange[1]}] see more ${r.countMatched} matched ${r.tokensGrouped} tokens`,
4072
4107
  textClose: null
4073
4108
  });
4074
- add = (t, s, o) => t == null ? {
4109
+ add = (r, s, o) => r == null ? {
4075
4110
  indexRange: [o, o],
4076
4111
  countGrouped: 1,
4077
4112
  countMatched: s.countMatched,
4078
4113
  tokensGrouped: s.tokens
4079
- } : (t.indexRange[1] = o, t.countGrouped += 1, t.countMatched += s.countMatched, t.tokensGrouped += s.tokens, t);
4114
+ } : (r.indexRange[1] = o, r.countGrouped += 1, r.countMatched += s.countMatched, r.tokensGrouped += s.tokens, r);
4080
4115
  }
4081
- const Jt = m.object({
4082
- snapshotName: m.string().optional().describe("Name of previously created DOM snapshot, to use"),
4083
- snapshot: ve.optional().describe(
4116
+ const Qt = h.object({
4117
+ snapshotName: h.string().optional().describe("Name of previously created DOM snapshot, to use"),
4118
+ snapshot: Ee.optional().describe(
4084
4119
  "DOM snapshot creation options JSON to automatically create snapshot"
4085
4120
  ),
4086
- parentUid: m.number().optional().describe("UID of parent node to browse. Omit to browse the root node"),
4087
- childsIndexRange: m.tuple([m.number(), m.number()]).optional().describe(
4121
+ parentUid: h.number().optional().describe("UID of parent node to browse. Omit to browse the root node"),
4122
+ childsIndexRange: h.tuple([h.number(), h.number()]).optional().describe(
4088
4123
  "Child index range to show [start, end]. Only use the exact ranges that appeared in previous snapshot results - do not modify, combine, or split them"
4089
4124
  )
4090
4125
  // maxCountTotal: z
@@ -4098,10 +4133,10 @@ const Jt = m.object({
4098
4133
  // maxCountGroup: z.number().default(10).describe('Maximum items per group'),
4099
4134
  // maxTokensGroup: z.number().default(1000).describe('Maximum tokens per group'),
4100
4135
  });
4101
- async function lo(r, t, s) {
4136
+ async function mo(t, r, s) {
4102
4137
  let o;
4103
4138
  try {
4104
- o = Jt.parse(r);
4139
+ o = Qt.parse(t);
4105
4140
  } catch (g) {
4106
4141
  return {
4107
4142
  error: F(g)
@@ -4125,7 +4160,7 @@ async function lo(r, t, s) {
4125
4160
  return {
4126
4161
  error: "Either snapshotName or snapshot must be provided, not both"
4127
4162
  };
4128
- let d, p = !1, h = !1;
4163
+ let d, p = !1, m = !1;
4129
4164
  if (e) {
4130
4165
  for (const g of f.browsers.values()) {
4131
4166
  for (const y of g.contexts.values()) {
@@ -4143,22 +4178,22 @@ async function lo(r, t, s) {
4143
4178
  error: `DOM snapshot "${e}" not found`
4144
4179
  };
4145
4180
  } else if (n) {
4146
- const g = await _t(
4181
+ const g = await Ht(
4147
4182
  n,
4148
- t,
4183
+ r,
4149
4184
  s
4150
4185
  );
4151
4186
  if (g.error != null)
4152
4187
  return {
4153
4188
  error: g.error
4154
4189
  };
4155
- d = g.domSnapshot, p = g.queryCreated, h = !0;
4190
+ d = g.domSnapshot, p = g.queryCreated, m = !0;
4156
4191
  } else
4157
4192
  return {
4158
4193
  error: "Either snapshotName or snapshot must be provided"
4159
4194
  };
4160
4195
  try {
4161
- const g = o.parentUid, y = Tt({
4196
+ const g = o.parentUid, y = Nt({
4162
4197
  tree: d.tree,
4163
4198
  request: {
4164
4199
  parentNodeId: g,
@@ -4170,12 +4205,12 @@ async function lo(r, t, s) {
4170
4205
  maxTokensGroup: u
4171
4206
  }
4172
4207
  },
4173
- indexRangeGroupStrategy: new ao()
4174
- }), w = Ct(y);
4208
+ indexRangeGroupStrategy: new ho()
4209
+ }), w = kt(y);
4175
4210
  return {
4176
4211
  domSnapshot: d,
4177
4212
  queryCreated: p,
4178
- snapshotCreated: h,
4213
+ snapshotCreated: m,
4179
4214
  parentUid: g,
4180
4215
  childsIndexRange: i,
4181
4216
  report: w
@@ -4186,16 +4221,16 @@ async function lo(r, t, s) {
4186
4221
  };
4187
4222
  }
4188
4223
  }
4189
- function co(r, t) {
4190
- r(
4224
+ function go(t, r) {
4225
+ t(
4191
4226
  "playwright-dom-snapshot-browse",
4192
4227
  {
4193
4228
  title: "Browse DOM Snapshot",
4194
4229
  description: "Browse and explore DOM. Use this to browse, analyze, explore, inspect, etc webpage structure and styles, find elements, or inspect page content",
4195
- inputSchema: Jt.shape
4230
+ inputSchema: Qt.shape
4196
4231
  },
4197
4232
  async (s, o) => {
4198
- const e = await lo(s, t, o);
4233
+ const e = await mo(s, r, o);
4199
4234
  if (e.error != null)
4200
4235
  return `Method: playwright-dom-snapshot-browse(${JSON.stringify(s)})
4201
4236
  ❌ Error: ${e.error}`;
@@ -4216,14 +4251,14 @@ ${e.report}`, n;
4216
4251
  }
4217
4252
  );
4218
4253
  }
4219
- function uo(r, t) {
4220
- t.browserCreate && As(r, t), t.browserList && Us(r, t), t.browserClose && qs(r, t), t.contextCreate && Gs(r, t), t.contextList && Js(r, t), t.contextClose && Ks(r, t), t.pageCreate && Ys(r, t), t.pageList && Zs(r, t), t.pageClose && eo(r, t), t.pageGoto && ro(r, t), t.domSnapshotQueryCreate && so(r, t), t.domSnapshotCreate && io(r, t), t.domSnapshotBrowse && co(r, t), console.log("Playwright manager");
4254
+ function wo(t, r) {
4255
+ r.browserCreate && Gs(t, r), r.browserList && Ws(t, r), r.browserClose && Hs(t, r), r.contextCreate && Qs(t, r), r.contextList && Vs(t, r), r.contextClose && Xs(t, r), r.pageCreate && ro(t, r), r.pageList && oo(t, r), r.pageClose && io(t, r), r.pageGoto && lo(t, r), r.domSnapshotQueryCreate && co(t, r), r.domSnapshotCreate && po(t, r), r.domSnapshotBrowse && go(t, r), console.log("Playwright manager");
4221
4256
  }
4222
- function fo(r) {
4223
- const { logFilePath: t } = r;
4257
+ function yo(t) {
4258
+ const { logFilePath: r } = t;
4224
4259
  return async function(o, e, n, i) {
4225
4260
  await ie({
4226
- logFilePath: t,
4261
+ logFilePath: r,
4227
4262
  message: "ERROR",
4228
4263
  data: {
4229
4264
  request: {
@@ -4241,15 +4276,15 @@ function fo(r) {
4241
4276
  });
4242
4277
  };
4243
4278
  }
4244
- const st = [
4279
+ const it = [
4245
4280
  "flemist-mcp.config.json",
4246
4281
  "flemist-mcp.config.json5",
4247
4282
  "flemist-mcp.config.yaml"
4248
4283
  ];
4249
- async function po(r) {
4250
- const t = k.resolve(r);
4251
- for (let s = 0, o = st.length; s < o; s++) {
4252
- const e = st[s], n = k.join(t, e);
4284
+ async function bo(t) {
4285
+ const r = k.resolve(t);
4286
+ for (let s = 0, o = it.length; s < o; s++) {
4287
+ const e = it[s], n = k.join(r, e);
4253
4288
  try {
4254
4289
  await j.promises.stat(n);
4255
4290
  } catch {
@@ -4271,26 +4306,28 @@ ${c instanceof Error ? c.message : String(c)}`);
4271
4306
  if (a === ".json5")
4272
4307
  return Ne.parse(i);
4273
4308
  if (a === ".yaml")
4274
- return ar.load(i);
4309
+ return dr.load(i);
4275
4310
  } catch (c) {
4276
4311
  throw new Error(`MCP Error: Failed to parse config file: ${n}
4277
4312
 
4278
4313
  ${c instanceof Error ? c.message : String(c)}`);
4279
4314
  }
4280
4315
  }
4281
- throw new Error(`MCP Error: No configuration file found in: ${t}
4316
+ throw new Error(`MCP Error: No configuration file found in: ${r}
4282
4317
 
4283
4318
  Expected one of:
4284
4319
  - flemist-mcp.config.json
4285
4320
  - flemist-mcp.config.json5
4286
4321
  - flemist-mcp.config.yaml`);
4287
4322
  }
4288
- const ho = {
4323
+ const So = {
4289
4324
  logDir: "tmp/mcp-project-tools/logs",
4290
4325
  tools: {
4291
4326
  processManager: {
4292
4327
  workingDir: null,
4293
4328
  commandLineRules: [],
4329
+ env: null,
4330
+ envCleanup: null,
4294
4331
  run: !0,
4295
4332
  status: !0,
4296
4333
  wait: !0,
@@ -4324,27 +4361,27 @@ const ho = {
4324
4361
  }
4325
4362
  }
4326
4363
  };
4327
- async function mo(r) {
4328
- const t = k.resolve(r), s = await po(t), o = k.join(t, ".flemist-mcpignore");
4364
+ async function xo(t) {
4365
+ const r = k.resolve(t), s = await bo(r), o = k.join(r, ".flemist-mcpignore");
4329
4366
  try {
4330
4367
  await j.promises.stat(o);
4331
4368
  } catch {
4332
4369
  throw new Error(`MCP Error: .flemist-mcpignore file not found in project directory.
4333
4370
 
4334
- Create .flemist-mcpignore file in: ${t}
4371
+ Create .flemist-mcpignore file in: ${r}
4335
4372
 
4336
4373
  This file contains glob patterns for files/directories to exclude from MCP operations.`);
4337
4374
  }
4338
- const e = ir(ho, s, {
4375
+ const e = ur(So, s, {
4339
4376
  arrayMerge(n, i) {
4340
4377
  return i;
4341
4378
  }
4342
4379
  });
4343
4380
  return e.tools?.processManager && (e.tools.processManager.workingDir = k.resolve(
4344
- t,
4381
+ r,
4345
4382
  e.tools.processManager.workingDir || ""
4346
4383
  )), e.tools?.fsManager && (e.tools.fsManager.workingDir = k.resolve(
4347
- t,
4384
+ r,
4348
4385
  e.tools.fsManager.workingDir || ""
4349
4386
  )), e.tools?.fsManager && (e.tools.fsManager.globsExclude = [
4350
4387
  {
@@ -4354,34 +4391,34 @@ This file contains glob patterns for files/directories to exclude from MCP opera
4354
4391
  },
4355
4392
  ...e.tools.fsManager.globsExclude || []
4356
4393
  ]), e.tools.fsManager?.globsExclude?.forEach((n, i, a) => {
4357
- n.valueType === "file-contains-patterns" && (a[i].value = k.resolve(t, n.value));
4358
- }), e.logDir = k.resolve(t, e.logDir), e;
4394
+ n.valueType === "file-contains-patterns" && (a[i].value = k.resolve(r, n.value));
4395
+ }), e.logDir = k.resolve(r, e.logDir), e;
4359
4396
  }
4360
- function Wt() {
4397
+ function Yt() {
4361
4398
  return `mcp_${(/* @__PURE__ */ new Date()).toISOString().substring(0, 19).replace(/T/, "_").replace(/:/g, "-")}.log`;
4362
4399
  }
4363
- function go(r) {
4364
- const t = ne(), s = wo();
4365
- return t.use(s), t;
4400
+ function $o(t) {
4401
+ const r = ne(), s = Io();
4402
+ return r.use(s), r;
4366
4403
  }
4367
- function wo(r) {
4368
- const t = ne.Router();
4369
- return t.use((s, o, e) => {
4404
+ function Io(t) {
4405
+ const r = ne.Router();
4406
+ return r.use((s, o, e) => {
4370
4407
  s.method === "OPTIONS" ? o.status(403).send("CORS forbidden") : e();
4371
- }), t.use(ne.json()), t;
4408
+ }), r.use(ne.json()), r;
4372
4409
  }
4373
- function yo(r) {
4374
- const t = ne.Router();
4375
- return t.use(lr({ authToken: r.authToken })), t.all("/mcp", pr(r)), t;
4410
+ function Mo(t) {
4411
+ const r = ne.Router();
4412
+ return r.use(fr({ authToken: t.authToken })), r.all("/mcp", wr(t)), r;
4376
4413
  }
4377
- function bo(r, t) {
4378
- return r.use(fo({ logFilePath: t.logFilePath })), new Promise((s, o) => {
4414
+ function To(t, r) {
4415
+ return t.use(yo({ logFilePath: r.logFilePath })), new Promise((s, o) => {
4379
4416
  let e;
4380
4417
  const n = () => {
4381
4418
  s(e);
4382
4419
  };
4383
4420
  try {
4384
- e = t.host ? r.listen(t.port ?? 0, t.host, n) : r.listen(t.port ?? 0, n), e.addListener("error", (i) => {
4421
+ e = r.host ? t.listen(r.port ?? 0, r.host, n) : t.listen(r.port ?? 0, n), e.addListener("error", (i) => {
4385
4422
  o(i);
4386
4423
  });
4387
4424
  } catch (i) {
@@ -4389,40 +4426,40 @@ function bo(r, t) {
4389
4426
  }
4390
4427
  });
4391
4428
  }
4392
- function So(r, t) {
4393
- if (!r.address())
4429
+ function Co(t, r) {
4430
+ if (!t.address())
4394
4431
  throw new Error(
4395
4432
  "Server address is not available. Check your DNS and host configuration."
4396
4433
  );
4397
- const o = r.address().family, e = r.address().port;
4398
- let n = r.address().address;
4434
+ const o = t.address().family, e = t.address().port;
4435
+ let n = t.address().address;
4399
4436
  n === "::" ? n = "localhost" : o === "IPv6" && (n = `[${n}]`);
4400
4437
  const i = `http://${o === "IPv6" ? `[${n}]` : n}:${e}`;
4401
4438
  return `Project Tools - MCP Server Started
4402
4439
 
4403
- Server Name: ${t.name}
4404
- Server Version: ${t.version}
4440
+ Server Name: ${r.name}
4441
+ Server Version: ${r.version}
4405
4442
  Server URL: ${i}/mcp
4406
4443
  SSE Endpoint: ${i}/sse
4407
4444
 
4408
- Log File: ${k.resolve(t.logFilePath)}`;
4445
+ Log File: ${k.resolve(r.logFilePath)}`;
4409
4446
  }
4410
- function xo(r, t) {
4411
- const s = k.join(t.logDir, Wt()), o = Pr(r, {
4447
+ function vo(t, r) {
4448
+ const s = k.join(r.logDir, Yt()), o = _r(t, {
4412
4449
  logFilePath: s
4413
4450
  });
4414
- t.tools.processManager && Lr(
4451
+ r.tools.processManager && qr(
4415
4452
  o,
4416
- t.tools.processManager
4417
- ), t.tools.fsManager && Ps(o, t.tools.fsManager), t.tools.playwrightManager && uo(
4453
+ r.tools.processManager
4454
+ ), r.tools.fsManager && _s(o, r.tools.fsManager), r.tools.playwrightManager && wo(
4418
4455
  o,
4419
- t.tools.playwrightManager
4420
- ), Er(o);
4456
+ r.tools.playwrightManager
4457
+ ), Dr(o);
4421
4458
  }
4422
- async function qo(r) {
4423
- const t = k.join(r.logDir, Wt()), s = go(), o = yo({
4424
- authToken: r.authToken,
4425
- logFilePath: t,
4459
+ async function Ho(t) {
4460
+ const r = k.join(t.logDir, Yt()), s = $o(), o = Mo({
4461
+ authToken: t.authToken,
4462
+ logFilePath: r,
4426
4463
  createMcpServer: async (n) => {
4427
4464
  const i = n.headers["x-project-name"];
4428
4465
  if (!i)
@@ -4436,42 +4473,42 @@ X-Project-Name header is missing. To configure MCP for this project:
4436
4473
  4. Create .mcp.json in project root with X-Project-Name header set to project name
4437
4474
  5. Ask user to add project to server's projects config if not already present
4438
4475
  6. Ask user to restart Claude Code`);
4439
- const a = r.projects[i];
4476
+ const a = t.projects[i];
4440
4477
  if (!a)
4441
4478
  throw new Error(`MCP Error: Project "${i}" not found in server configuration.
4442
4479
 
4443
4480
  Ask user to:
4444
4481
  1. Add project to server's projects config: projects: { "${i}": "<project-path>" }
4445
4482
  2. Restart MCP server`);
4446
- const c = await mo(a), l = new Kt({
4447
- title: r.title,
4448
- name: r.name,
4449
- version: r.version
4483
+ const c = await xo(a), l = new Vt({
4484
+ title: t.title,
4485
+ name: t.name,
4486
+ version: t.version
4450
4487
  });
4451
- return xo(l, c), l;
4488
+ return vo(l, c), l;
4452
4489
  }
4453
4490
  });
4454
4491
  s.use(o);
4455
- const e = await bo(s, {
4456
- host: r.host,
4457
- port: r.port,
4458
- logFilePath: t
4492
+ const e = await To(s, {
4493
+ host: t.host,
4494
+ port: t.port,
4495
+ logFilePath: r
4459
4496
  });
4460
4497
  return console.log(
4461
- So(e, {
4462
- title: r.title,
4463
- name: r.name,
4464
- version: r.version,
4465
- logFilePath: t
4498
+ Co(e, {
4499
+ title: t.title,
4500
+ name: t.name,
4501
+ version: t.version,
4502
+ logFilePath: r
4466
4503
  })
4467
4504
  ), e;
4468
4505
  }
4469
4506
  export {
4470
- jo as A,
4471
- Uo as S,
4472
- zo as a,
4473
- Ao as b,
4474
- po as l,
4475
- Qr as p,
4476
- qo as s
4507
+ Ko as A,
4508
+ Wo as S,
4509
+ Jo as a,
4510
+ Go as b,
4511
+ bo as l,
4512
+ ts as p,
4513
+ Ho as s
4477
4514
  };