@flemist/mcp-project-tools 5.0.1 → 5.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,7 +1,7 @@
|
|
|
1
1
|
import ne from "express";
|
|
2
2
|
import { McpServer as Zt } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
3
|
import { randomUUID as Xt } from "crypto";
|
|
4
|
-
import * as
|
|
4
|
+
import * as U from "fs";
|
|
5
5
|
import * as k from "path";
|
|
6
6
|
import { StreamableHTTPServerTransport as er } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
7
7
|
import { spawn as tr } from "child_process";
|
|
@@ -16,34 +16,34 @@ import { webkit as lr, firefox as cr, chromium as ur } from "playwright";
|
|
|
16
16
|
import dr from "deepmerge";
|
|
17
17
|
import Ne from "json5";
|
|
18
18
|
import fr from "js-yaml";
|
|
19
|
-
function pr(
|
|
20
|
-
const { authToken:
|
|
19
|
+
function pr(r) {
|
|
20
|
+
const { authToken: t } = r;
|
|
21
21
|
return function(o, e, n) {
|
|
22
|
-
if ((o.query.token || o.headers.authorization?.replace("Bearer ", "")) !==
|
|
22
|
+
if ((o.query.token || o.headers.authorization?.replace("Bearer ", "")) !== t) {
|
|
23
23
|
e.status(401).json({ error: "Unauthorized" });
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
26
|
n();
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
async function ie(
|
|
30
|
-
const { logFilePath:
|
|
29
|
+
async function ie(r) {
|
|
30
|
+
const { logFilePath: t, message: s, data: o } = r;
|
|
31
31
|
try {
|
|
32
32
|
const e = (/* @__PURE__ */ new Date()).toISOString().replace(/[TZ]/g, " ").trim(), n = typeof o == "string" ? o : JSON.stringify(o, null, 2), i = `[${e}] ${s}
|
|
33
33
|
${n}
|
|
34
34
|
|
|
35
35
|
`;
|
|
36
|
-
await
|
|
36
|
+
await U.promises.mkdir(k.dirname(t), { recursive: !0 }), await U.promises.appendFile(t, i);
|
|
37
37
|
} catch (e) {
|
|
38
38
|
console.error(`Failed to log "${s}":`, e);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
const ae = /* @__PURE__ */ new Map();
|
|
42
|
-
function hr(
|
|
43
|
-
return
|
|
42
|
+
function hr(r) {
|
|
43
|
+
return r.headers["mcp-session-id"] || r.headers["x-session-id"] || r.query.token;
|
|
44
44
|
}
|
|
45
|
-
async function mr(
|
|
46
|
-
const s = await
|
|
45
|
+
async function mr(r, t) {
|
|
46
|
+
const s = await t.createMcpServer(r), o = new er({
|
|
47
47
|
sessionIdGenerator: Xt,
|
|
48
48
|
onsessioninitialized: (n) => {
|
|
49
49
|
ae.set(n, o);
|
|
@@ -66,28 +66,28 @@ async function mr(t, r) {
|
|
|
66
66
|
throw await e(), n;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
async function gr(
|
|
69
|
+
async function gr(r, t, s, o) {
|
|
70
70
|
await ie({
|
|
71
71
|
logFilePath: s.logFilePath,
|
|
72
72
|
message: "REQUEST",
|
|
73
|
-
data:
|
|
73
|
+
data: r.body
|
|
74
74
|
});
|
|
75
75
|
let e = o ? ae.get(o) : null;
|
|
76
|
-
e || (e = await mr(
|
|
76
|
+
e || (e = await mr(r, s)), await e.handleRequest(r, t, r.body);
|
|
77
77
|
}
|
|
78
|
-
async function wr(
|
|
78
|
+
async function wr(r, t, s) {
|
|
79
79
|
const o = s ? ae.get(s) : null;
|
|
80
80
|
if (!o) {
|
|
81
|
-
|
|
81
|
+
t.status(400).json({ error: "No valid session found" });
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
|
-
await o.handleRequest(
|
|
84
|
+
await o.handleRequest(r, t);
|
|
85
85
|
}
|
|
86
|
-
function yr(
|
|
86
|
+
function yr(r) {
|
|
87
87
|
return async function(s, o) {
|
|
88
88
|
try {
|
|
89
89
|
const e = hr(s);
|
|
90
|
-
s.method === "POST" ? await gr(s, o,
|
|
90
|
+
s.method === "POST" ? await gr(s, o, r, e) : s.method === "GET" ? await wr(s, o, e) : o.status(405).json({ error: "Method not allowed" });
|
|
91
91
|
} catch (e) {
|
|
92
92
|
console.error("Unhandled error in streamableHttpHandler", e), o.status(500).json({
|
|
93
93
|
error: "Internal server error: " + (e instanceof Error ? e.message : "Unknown error")
|
|
@@ -98,11 +98,11 @@ function yr(t) {
|
|
|
98
98
|
const Y = /* @__PURE__ */ new Map();
|
|
99
99
|
let br = 0;
|
|
100
100
|
const ke = 10, Sr = 1800 * 1e3, J = 1e4, Q = 2e3, xr = 5e3;
|
|
101
|
-
function Ir(
|
|
102
|
-
const { commandLine:
|
|
101
|
+
function Ir(r) {
|
|
102
|
+
const { commandLine: t, commandLineRules: s } = r;
|
|
103
103
|
let o = !1;
|
|
104
104
|
for (const e of s)
|
|
105
|
-
if (new RegExp(e.regexp).test(
|
|
105
|
+
if (new RegExp(e.regexp).test(t))
|
|
106
106
|
switch (e.rule) {
|
|
107
107
|
case "allow":
|
|
108
108
|
o = !0;
|
|
@@ -123,49 +123,49 @@ function Mr() {
|
|
|
123
123
|
if (Oe)
|
|
124
124
|
return;
|
|
125
125
|
Oe = !0;
|
|
126
|
-
const
|
|
126
|
+
const r = () => {
|
|
127
127
|
console.log("Auto-killing all child processes...");
|
|
128
|
-
for (const [
|
|
128
|
+
for (const [t, s] of Array.from(Y.entries()))
|
|
129
129
|
if (s.isRunning && s.pid)
|
|
130
130
|
try {
|
|
131
131
|
he(s.pid, "SIGKILL");
|
|
132
132
|
} catch (o) {
|
|
133
|
-
console.error(`Error killing process ${
|
|
133
|
+
console.error(`Error killing process ${t}:`, o);
|
|
134
134
|
}
|
|
135
135
|
process.exit(0);
|
|
136
136
|
};
|
|
137
|
-
process.on("SIGINT",
|
|
137
|
+
process.on("SIGINT", r), process.on("SIGTERM", r);
|
|
138
138
|
}
|
|
139
139
|
function ge() {
|
|
140
|
-
const
|
|
140
|
+
const r = Date.now(), t = [];
|
|
141
141
|
for (const [s, o] of Array.from(Y.entries()))
|
|
142
|
-
!o.isRunning && o.endTime &&
|
|
143
|
-
for (const s of
|
|
142
|
+
!o.isRunning && o.endTime && r - o.endTime.getTime() > Sr && t.push(s);
|
|
143
|
+
for (const s of t)
|
|
144
144
|
Y.delete(s);
|
|
145
145
|
}
|
|
146
|
-
function Re(
|
|
147
|
-
return
|
|
146
|
+
function Re(r) {
|
|
147
|
+
return r.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
148
148
|
}
|
|
149
149
|
const De = "[/\\\\]";
|
|
150
|
-
function at(
|
|
151
|
-
const s =
|
|
150
|
+
function at(r, t) {
|
|
151
|
+
const s = r.replace(/[\\/]+$/, "");
|
|
152
152
|
let o;
|
|
153
|
-
return
|
|
153
|
+
return t ? o = s.split(/[\\/]/).map(Re).join(De) : o = Re(s), o += `(?=${De}|$)`, new RegExp(o, t ? "gi" : "g");
|
|
154
154
|
}
|
|
155
|
-
function Tr(
|
|
156
|
-
const e = at(
|
|
157
|
-
return
|
|
155
|
+
function Tr(r, t, s, o) {
|
|
156
|
+
const e = at(t, o);
|
|
157
|
+
return r.replace(e, (n) => s + n.slice(t.length));
|
|
158
158
|
}
|
|
159
|
-
function
|
|
159
|
+
function vr(r, t, s, o) {
|
|
160
160
|
const e = process.platform === "win32", n = {};
|
|
161
161
|
if (s !== "clear") if (s === "replaceServerPaths" || s === "deleteServerPaths") {
|
|
162
|
-
const i = Fe(
|
|
162
|
+
const i = Fe(r, e), a = Fe(t, e);
|
|
163
163
|
if (i !== a) {
|
|
164
|
-
const l = at(
|
|
164
|
+
const l = at(r, e);
|
|
165
165
|
for (const u in process.env) {
|
|
166
166
|
if (!Object.prototype.hasOwnProperty.call(process.env, u)) continue;
|
|
167
167
|
const f = process.env[u];
|
|
168
|
-
f != null && (l.lastIndex = 0, l.test(f) ? s === "replaceServerPaths" && (n[u] = Tr(f,
|
|
168
|
+
f != null && (l.lastIndex = 0, l.test(f) ? s === "replaceServerPaths" && (n[u] = Tr(f, r, t, e)) : n[u] = f);
|
|
169
169
|
}
|
|
170
170
|
} else
|
|
171
171
|
for (const l in process.env) {
|
|
@@ -187,41 +187,41 @@ function Cr(t, r, s, o) {
|
|
|
187
187
|
}
|
|
188
188
|
return n;
|
|
189
189
|
}
|
|
190
|
-
function Fe(
|
|
191
|
-
const s = k.normalize(
|
|
192
|
-
return
|
|
190
|
+
function Fe(r, t) {
|
|
191
|
+
const s = k.normalize(r).replace(/[\\/]+$/, "");
|
|
192
|
+
return t ? s.toLowerCase() : s;
|
|
193
193
|
}
|
|
194
|
-
const
|
|
194
|
+
const Cr = 1800 * 1e3, Pe = /* @__PURE__ */ new Map();
|
|
195
195
|
let Er = 0;
|
|
196
196
|
function Nr() {
|
|
197
197
|
return ++Er;
|
|
198
198
|
}
|
|
199
|
-
function lt(
|
|
200
|
-
let
|
|
201
|
-
return
|
|
199
|
+
function lt(r) {
|
|
200
|
+
let t = Pe.get(r);
|
|
201
|
+
return t == null && (t = {
|
|
202
202
|
storedOutputs: /* @__PURE__ */ new Map()
|
|
203
|
-
}, Pe.set(
|
|
203
|
+
}, Pe.set(r, t)), t;
|
|
204
204
|
}
|
|
205
|
-
function ct(
|
|
206
|
-
return typeof
|
|
205
|
+
function ct(r) {
|
|
206
|
+
return typeof r == "function" ? r() : r;
|
|
207
207
|
}
|
|
208
|
-
function ut(
|
|
208
|
+
function ut(r, t) {
|
|
209
209
|
return setTimeout(() => {
|
|
210
|
-
|
|
211
|
-
},
|
|
210
|
+
r.storedOutputs.delete(t);
|
|
211
|
+
}, Cr);
|
|
212
212
|
}
|
|
213
|
-
function kr(
|
|
214
|
-
clearTimeout(s.cleanupTimer), s.cleanupTimer = ut(
|
|
213
|
+
function kr(r, t, s) {
|
|
214
|
+
clearTimeout(s.cleanupTimer), s.cleanupTimer = ut(r, t);
|
|
215
215
|
}
|
|
216
|
-
function Or(
|
|
217
|
-
const { sessionId:
|
|
216
|
+
function Or(r) {
|
|
217
|
+
const { sessionId: t, source: s } = r, o = lt(t), e = Nr(), n = {
|
|
218
218
|
source: s,
|
|
219
219
|
cleanupTimer: ut(o, e)
|
|
220
220
|
};
|
|
221
221
|
return o.storedOutputs.set(e, n), e;
|
|
222
222
|
}
|
|
223
|
-
function dt(
|
|
224
|
-
const { sessionId:
|
|
223
|
+
function dt(r) {
|
|
224
|
+
const { sessionId: t, outputId: s, range: o } = r, [e, n] = o, i = lt(t), a = i.storedOutputs.get(s);
|
|
225
225
|
if (a == null)
|
|
226
226
|
return {
|
|
227
227
|
content: "",
|
|
@@ -233,12 +233,12 @@ function dt(t) {
|
|
|
233
233
|
const c = ct(a.source), l = c.length, u = Math.min(Math.max(e, 0), l), f = Math.min(Math.max(n, 0), l);
|
|
234
234
|
return { content: c.substring(u, f), total: l, range: [u, f] };
|
|
235
235
|
}
|
|
236
|
-
function we(
|
|
237
|
-
const { sessionId:
|
|
236
|
+
function we(r) {
|
|
237
|
+
const { sessionId: t, source: s, limit: o } = r, e = ct(s);
|
|
238
238
|
if (e.length <= o)
|
|
239
239
|
return { content: e, outputId: null };
|
|
240
|
-
const n = Or({ sessionId:
|
|
241
|
-
sessionId:
|
|
240
|
+
const n = Or({ sessionId: t, source: s }), i = dt({
|
|
241
|
+
sessionId: t,
|
|
242
242
|
outputId: n,
|
|
243
243
|
range: [0, o]
|
|
244
244
|
}), a = `
|
|
@@ -248,8 +248,8 @@ function we(t) {
|
|
|
248
248
|
outputId: n
|
|
249
249
|
};
|
|
250
250
|
}
|
|
251
|
-
function F(
|
|
252
|
-
return `Invalid arguments: ${
|
|
251
|
+
function F(r) {
|
|
252
|
+
return `Invalid arguments: ${r instanceof Error ? r.message : "Unknown error"}.
|
|
253
253
|
|
|
254
254
|
Provide valid parameters according to schema.`;
|
|
255
255
|
}
|
|
@@ -265,23 +265,23 @@ const ft = m.object({
|
|
|
265
265
|
`Character range to retrieve. Maximum range size: ${J}.`
|
|
266
266
|
)
|
|
267
267
|
});
|
|
268
|
-
function Dr(
|
|
268
|
+
function Dr(r, t) {
|
|
269
269
|
let s;
|
|
270
270
|
try {
|
|
271
|
-
s = pt.parse(
|
|
271
|
+
s = pt.parse(r);
|
|
272
272
|
} catch (i) {
|
|
273
273
|
return {
|
|
274
274
|
error: F(i)
|
|
275
275
|
};
|
|
276
276
|
}
|
|
277
|
-
if (!
|
|
277
|
+
if (!t.sessionId)
|
|
278
278
|
return {
|
|
279
279
|
error: "Session ID is required"
|
|
280
280
|
};
|
|
281
281
|
let { from: o, toExclusive: e } = s.range;
|
|
282
282
|
e <= o && (e = o), e - o > J && (e = o + J);
|
|
283
283
|
const n = dt({
|
|
284
|
-
sessionId:
|
|
284
|
+
sessionId: t.sessionId,
|
|
285
285
|
outputId: s.outputId,
|
|
286
286
|
range: [o, e]
|
|
287
287
|
});
|
|
@@ -291,21 +291,21 @@ function Dr(t, r) {
|
|
|
291
291
|
range: n.range
|
|
292
292
|
};
|
|
293
293
|
}
|
|
294
|
-
function Fr(
|
|
295
|
-
|
|
294
|
+
function Fr(r) {
|
|
295
|
+
r(
|
|
296
296
|
"output-read",
|
|
297
297
|
{
|
|
298
298
|
title: "Read Stored Output Range",
|
|
299
299
|
description: "Read any range from stored output. Use outputId from truncation message and specify character range [from, to).",
|
|
300
300
|
inputSchema: pt.shape
|
|
301
301
|
},
|
|
302
|
-
async (
|
|
303
|
-
const o = Dr(
|
|
302
|
+
async (t, s) => {
|
|
303
|
+
const o = Dr(t, s);
|
|
304
304
|
if (o.error != null)
|
|
305
|
-
return `Method: output-read(${JSON.stringify(
|
|
305
|
+
return `Method: output-read(${JSON.stringify(t)})
|
|
306
306
|
❌ Error: ${o.error}`;
|
|
307
307
|
const [e, n] = o.range, i = o.total;
|
|
308
|
-
let a = `Method: output-read(${JSON.stringify(
|
|
308
|
+
let a = `Method: output-read(${JSON.stringify(t)})
|
|
309
309
|
showing [${e}, ${n}) of ${i} chars`;
|
|
310
310
|
return e >= i && (a += `
|
|
311
311
|
⚠️ Warning: requested range is beyond content (total: ${i} chars)`), a += `
|
|
@@ -314,8 +314,8 @@ ${o.content}`, a;
|
|
|
314
314
|
}
|
|
315
315
|
);
|
|
316
316
|
}
|
|
317
|
-
function Pr(
|
|
318
|
-
Fr(
|
|
317
|
+
function Pr(r) {
|
|
318
|
+
Fr(r);
|
|
319
319
|
}
|
|
320
320
|
const ht = m.object({
|
|
321
321
|
id: m.number().describe(
|
|
@@ -325,11 +325,11 @@ const ht = m.object({
|
|
|
325
325
|
`Maximum output characters to return. Truncated output can be retrieved via output-read tool using outputId from truncation message. Maximum: ${J}. Default: ${Q}`
|
|
326
326
|
)
|
|
327
327
|
});
|
|
328
|
-
async function ye(
|
|
328
|
+
async function ye(r, t, s) {
|
|
329
329
|
ge();
|
|
330
330
|
let o;
|
|
331
331
|
try {
|
|
332
|
-
o = ht.parse(
|
|
332
|
+
o = ht.parse(r);
|
|
333
333
|
} catch (c) {
|
|
334
334
|
return {
|
|
335
335
|
error: F(c)
|
|
@@ -351,7 +351,7 @@ async function ye(t, r, s) {
|
|
|
351
351
|
}).content;
|
|
352
352
|
return {
|
|
353
353
|
id: i.id,
|
|
354
|
-
cwd: k.relative(
|
|
354
|
+
cwd: k.relative(t.workingDir || "", i.cwd),
|
|
355
355
|
commandLine: i.commandLine,
|
|
356
356
|
pid: i.pid,
|
|
357
357
|
startTime: i.startTime.toISOString().replace(/[TZ]/g, " ").trim(),
|
|
@@ -362,8 +362,8 @@ async function ye(t, r, s) {
|
|
|
362
362
|
error: i.error
|
|
363
363
|
};
|
|
364
364
|
}
|
|
365
|
-
function Br(
|
|
366
|
-
|
|
365
|
+
function Br(r, t) {
|
|
366
|
+
r(
|
|
367
367
|
"process-status",
|
|
368
368
|
{
|
|
369
369
|
title: "Get Host Machine Process Status",
|
|
@@ -371,7 +371,7 @@ function Br(t, r) {
|
|
|
371
371
|
inputSchema: ht.shape
|
|
372
372
|
},
|
|
373
373
|
async (s, o) => {
|
|
374
|
-
const e = await ye(s,
|
|
374
|
+
const e = await ye(s, t, o);
|
|
375
375
|
if (!("output" in e))
|
|
376
376
|
return `Method: process-status(${JSON.stringify(s)})
|
|
377
377
|
❌ Error: ${e.error}`;
|
|
@@ -384,12 +384,12 @@ ${n.trim()}`;
|
|
|
384
384
|
}
|
|
385
385
|
);
|
|
386
386
|
}
|
|
387
|
-
function mt(
|
|
388
|
-
he(
|
|
389
|
-
|
|
387
|
+
function mt(r) {
|
|
388
|
+
he(r, "SIGTERM", (t) => {
|
|
389
|
+
t && !t.message.includes("not found") && console.error(`Error sending SIGTERM to process ${r}:`, t);
|
|
390
390
|
}), setTimeout(() => {
|
|
391
|
-
he(
|
|
392
|
-
|
|
391
|
+
he(r, "SIGKILL", (t) => {
|
|
392
|
+
t && !t.message.includes("not found") && console.error(`Error sending SIGKILL to process ${r}:`, t);
|
|
393
393
|
});
|
|
394
394
|
}, xr);
|
|
395
395
|
}
|
|
@@ -407,10 +407,10 @@ const gt = m.object({
|
|
|
407
407
|
`Maximum output characters to return. Truncated output can be retrieved via output-read tool using outputId from truncation message. Maximum: ${J}. Default: ${Q}`
|
|
408
408
|
)
|
|
409
409
|
});
|
|
410
|
-
async function wt(
|
|
410
|
+
async function wt(r, t, s) {
|
|
411
411
|
let o;
|
|
412
412
|
try {
|
|
413
|
-
o = gt.parse(
|
|
413
|
+
o = gt.parse(r);
|
|
414
414
|
} catch (h) {
|
|
415
415
|
return {
|
|
416
416
|
error: F(h)
|
|
@@ -430,14 +430,14 @@ async function wt(t, r, s) {
|
|
|
430
430
|
});
|
|
431
431
|
const d = (Date.now() - l) / 1e3;
|
|
432
432
|
return {
|
|
433
|
-
...await ye({ id: e, outputLimit: a },
|
|
433
|
+
...await ye({ id: e, outputLimit: a }, t, s),
|
|
434
434
|
waitDuration: d,
|
|
435
435
|
waitTimeExceeded: u,
|
|
436
436
|
autoKillExecuted: f
|
|
437
437
|
};
|
|
438
438
|
}
|
|
439
|
-
function Lr(
|
|
440
|
-
|
|
439
|
+
function Lr(r, t) {
|
|
440
|
+
r(
|
|
441
441
|
"process-wait",
|
|
442
442
|
{
|
|
443
443
|
title: "Wait for Host Machine Process",
|
|
@@ -445,7 +445,7 @@ function Lr(t, r) {
|
|
|
445
445
|
inputSchema: gt.shape
|
|
446
446
|
},
|
|
447
447
|
async (s, o) => {
|
|
448
|
-
const e = await wt(s,
|
|
448
|
+
const e = await wt(s, t, o);
|
|
449
449
|
if (!("output" in e))
|
|
450
450
|
return `Method: process-wait(${JSON.stringify(s)})
|
|
451
451
|
❌ Error: ${e.error}`;
|
|
@@ -458,17 +458,17 @@ ${n.trim()}`;
|
|
|
458
458
|
}
|
|
459
459
|
);
|
|
460
460
|
}
|
|
461
|
-
function H(
|
|
462
|
-
return
|
|
461
|
+
function H(r) {
|
|
462
|
+
return r.replace(/\\/g, "/");
|
|
463
463
|
}
|
|
464
|
-
function be(
|
|
465
|
-
if (!
|
|
464
|
+
function be(r, t) {
|
|
465
|
+
if (!r)
|
|
466
466
|
return { error: "Working directory is not configured" };
|
|
467
|
-
const s = H(k.resolve(
|
|
468
|
-
k.resolve(
|
|
467
|
+
const s = H(k.resolve(r)), o = H(
|
|
468
|
+
k.resolve(r, t || "")
|
|
469
469
|
);
|
|
470
470
|
return !o.startsWith(s + "/") && o !== s ? {
|
|
471
|
-
error: `Path "${
|
|
471
|
+
error: `Path "${t}" escapes root directory "${r}". Resolved path: "${o}"`
|
|
472
472
|
} : { path: o };
|
|
473
473
|
}
|
|
474
474
|
const yt = m.object({
|
|
@@ -488,18 +488,18 @@ const yt = m.object({
|
|
|
488
488
|
`Maximum output characters to return. Truncated output can be retrieved via output-read tool using outputId from truncation message. Maximum: ${J}. Default: ${Q}`
|
|
489
489
|
)
|
|
490
490
|
});
|
|
491
|
-
async function Ar(
|
|
491
|
+
async function Ar(r, t, s) {
|
|
492
492
|
ge();
|
|
493
493
|
let o;
|
|
494
494
|
try {
|
|
495
|
-
o = yt.parse(
|
|
495
|
+
o = yt.parse(r);
|
|
496
496
|
} catch (h) {
|
|
497
497
|
return {
|
|
498
498
|
error: F(h)
|
|
499
499
|
};
|
|
500
500
|
}
|
|
501
|
-
const { commandLine: e, waitTime: n, autoKill: i, outputLimit: a } = o, { commandLineRules: c } =
|
|
502
|
-
|
|
501
|
+
const { commandLine: e, waitTime: n, autoKill: i, outputLimit: a } = o, { commandLineRules: c } = t, l = be(
|
|
502
|
+
t.workingDir,
|
|
503
503
|
o.relativeRootDir
|
|
504
504
|
);
|
|
505
505
|
if ("error" in l)
|
|
@@ -533,11 +533,11 @@ To use this command line, ask the user to modify the command line rules in the c
|
|
|
533
533
|
};
|
|
534
534
|
Y.set(d, p);
|
|
535
535
|
try {
|
|
536
|
-
const h =
|
|
536
|
+
const h = vr(
|
|
537
537
|
process.cwd(),
|
|
538
538
|
u,
|
|
539
|
-
|
|
540
|
-
|
|
539
|
+
t.envCleanup ?? "deleteServerPaths",
|
|
540
|
+
t.env
|
|
541
541
|
), g = tr(e, [], {
|
|
542
542
|
shell: !0,
|
|
543
543
|
cwd: u,
|
|
@@ -546,8 +546,8 @@ To use this command line, ask the user to modify the command line rules in the c
|
|
|
546
546
|
});
|
|
547
547
|
p.pid = g.pid;
|
|
548
548
|
const y = (w) => {
|
|
549
|
-
const
|
|
550
|
-
p.output +=
|
|
549
|
+
const I = w.toString();
|
|
550
|
+
p.output += I, console.log(I);
|
|
551
551
|
};
|
|
552
552
|
return g.stdout?.on("data", y), g.stderr?.on("data", y), g.on("close", (w) => {
|
|
553
553
|
p.isRunning = !1, p.endTime = /* @__PURE__ */ new Date(), p.exitCode = w !== null ? w : void 0, console.log(`Process ${d} (${e}) exited with code ${w}`);
|
|
@@ -555,17 +555,17 @@ To use this command line, ask the user to modify the command line rules in the c
|
|
|
555
555
|
p.isRunning = !1, p.endTime = /* @__PURE__ */ new Date(), p.error = w.message, console.error(`Process ${d} error:`, w.message);
|
|
556
556
|
}), n != null ? wt(
|
|
557
557
|
{ id: d, waitTime: n, autoKill: i, outputLimit: a },
|
|
558
|
-
|
|
558
|
+
t,
|
|
559
559
|
s
|
|
560
|
-
) : ye({ id: d, outputLimit: a },
|
|
560
|
+
) : ye({ id: d, outputLimit: a }, t, s);
|
|
561
561
|
} catch (h) {
|
|
562
562
|
return p.isRunning = !1, p.endTime = /* @__PURE__ */ new Date(), p.error = h instanceof Error ? h.message : "Unknown error", { error: p.error };
|
|
563
563
|
}
|
|
564
564
|
}
|
|
565
|
-
function zr(
|
|
566
|
-
const s =
|
|
565
|
+
function zr(r, t) {
|
|
566
|
+
const s = t.commandLineRules.map((o) => `${o.rule.toUpperCase()}: ${o.regexp} (${o.note})`).join(`
|
|
567
567
|
`);
|
|
568
|
-
|
|
568
|
+
r(
|
|
569
569
|
"process-run",
|
|
570
570
|
{
|
|
571
571
|
title: "Execute Command Line on Host Machine",
|
|
@@ -574,7 +574,7 @@ ${s}`,
|
|
|
574
574
|
inputSchema: yt.shape
|
|
575
575
|
},
|
|
576
576
|
async (o, e) => {
|
|
577
|
-
const n = await Ar(o,
|
|
577
|
+
const n = await Ar(o, t, e);
|
|
578
578
|
if (!("output" in n))
|
|
579
579
|
return `Method: process-run(${JSON.stringify(o)})
|
|
580
580
|
❌ Error: ${n.error}`;
|
|
@@ -601,11 +601,11 @@ const bt = m.object({
|
|
|
601
601
|
'Specific process data fields to include in the response. If omitted, returns all available fields. Fields id, isRunning, and commandLine are always included. Available fields: id, cwd, commandLine, pid, startTime, endTime, exitCode, isRunning, output, error. Examples: ["id", "commandLine", "isRunning"] for minimal info, ["id", "output", "exitCode"] for execution results'
|
|
602
602
|
)
|
|
603
603
|
});
|
|
604
|
-
async function
|
|
604
|
+
async function _r(r, t) {
|
|
605
605
|
ge();
|
|
606
606
|
let s;
|
|
607
607
|
try {
|
|
608
|
-
s = bt.parse(
|
|
608
|
+
s = bt.parse(r);
|
|
609
609
|
} catch (l) {
|
|
610
610
|
return {
|
|
611
611
|
error: F(l)
|
|
@@ -624,7 +624,7 @@ async function Ur(t, r) {
|
|
|
624
624
|
return n && (a = a.filter((l) => l.isRunning)), { processes: a.map((l) => {
|
|
625
625
|
let u = {
|
|
626
626
|
id: l.id,
|
|
627
|
-
cwd: k.relative(
|
|
627
|
+
cwd: k.relative(t.workingDir || "", l.cwd),
|
|
628
628
|
commandLine: l.commandLine,
|
|
629
629
|
pid: l.pid,
|
|
630
630
|
startTime: l.startTime.toISOString().replace(/[TZ]/g, " ").trim(),
|
|
@@ -644,8 +644,8 @@ async function Ur(t, r) {
|
|
|
644
644
|
return u;
|
|
645
645
|
}) };
|
|
646
646
|
}
|
|
647
|
-
function
|
|
648
|
-
|
|
647
|
+
function Ur(r, t) {
|
|
648
|
+
r(
|
|
649
649
|
"process-list",
|
|
650
650
|
{
|
|
651
651
|
title: "List Host Machine Processes",
|
|
@@ -653,7 +653,7 @@ function jr(t, r) {
|
|
|
653
653
|
inputSchema: bt.shape
|
|
654
654
|
},
|
|
655
655
|
async (s) => {
|
|
656
|
-
const o = await
|
|
656
|
+
const o = await _r(s, t);
|
|
657
657
|
if (o.error != null)
|
|
658
658
|
return `Method: process-list(${JSON.stringify(s)})
|
|
659
659
|
❌ Error: ${o.error}`;
|
|
@@ -672,16 +672,16 @@ const St = m.object({
|
|
|
672
672
|
"Process ID of the process to terminate. Get process IDs using process-list. The process must be currently running. Examples: 1, 42, 123"
|
|
673
673
|
)
|
|
674
674
|
});
|
|
675
|
-
function
|
|
676
|
-
let
|
|
675
|
+
function jr(r) {
|
|
676
|
+
let t;
|
|
677
677
|
try {
|
|
678
|
-
|
|
678
|
+
t = St.parse(r);
|
|
679
679
|
} catch (e) {
|
|
680
680
|
return {
|
|
681
681
|
error: F(e)
|
|
682
682
|
};
|
|
683
683
|
}
|
|
684
|
-
const { id: s } =
|
|
684
|
+
const { id: s } = t, o = Y.get(s);
|
|
685
685
|
if (!o)
|
|
686
686
|
return {
|
|
687
687
|
error: `Process ${s} not found. The process may have already completed, been cleaned up after 30 minutes, or the ID may be incorrect. Use process-list to see available processes and their current status.`
|
|
@@ -702,8 +702,8 @@ function qr(t) {
|
|
|
702
702
|
};
|
|
703
703
|
}
|
|
704
704
|
}
|
|
705
|
-
function
|
|
706
|
-
|
|
705
|
+
function qr(r, t) {
|
|
706
|
+
r(
|
|
707
707
|
"process-kill",
|
|
708
708
|
{
|
|
709
709
|
title: "Kill Host Machine Process",
|
|
@@ -711,38 +711,38 @@ function _r(t, r) {
|
|
|
711
711
|
inputSchema: St.shape
|
|
712
712
|
},
|
|
713
713
|
async (s) => {
|
|
714
|
-
const o =
|
|
714
|
+
const o = jr(s);
|
|
715
715
|
return o.error != null ? `Method: process-kill(${JSON.stringify(s)})
|
|
716
716
|
❌ Error: ${o.error}` : `Method: process-kill(${JSON.stringify(s)})
|
|
717
717
|
${JSON.stringify(o, null, 2)}`;
|
|
718
718
|
}
|
|
719
719
|
);
|
|
720
720
|
}
|
|
721
|
-
function Gr(
|
|
722
|
-
Mr(),
|
|
723
|
-
const s =
|
|
721
|
+
function Gr(r, t) {
|
|
722
|
+
Mr(), t.run && zr(r, t), t.status && Br(r, t), t.wait && Lr(r, t), t.list && Ur(r, t), t.kill && qr(r);
|
|
723
|
+
const s = t.commandLineRules?.map(
|
|
724
724
|
(o) => `${o.rule.toUpperCase()}: ${o.regexp} (${o.note})`
|
|
725
725
|
) || [];
|
|
726
726
|
console.log(
|
|
727
727
|
`Process manager:
|
|
728
|
-
- Working directory: ${k.resolve(
|
|
729
|
-
- Command line rules: ${
|
|
728
|
+
- Working directory: ${k.resolve(t.workingDir || "")}
|
|
729
|
+
- Command line rules: ${t.commandLineRules?.length || 0} rules configured:
|
|
730
730
|
${s.map((o) => `- ${o}`).join(`
|
|
731
731
|
`)}
|
|
732
732
|
`
|
|
733
733
|
);
|
|
734
734
|
}
|
|
735
|
-
function Jr(
|
|
735
|
+
function Jr(r, t) {
|
|
736
736
|
return function(o, e, n) {
|
|
737
737
|
const i = async (...a) => {
|
|
738
738
|
await ie({
|
|
739
|
-
logFilePath:
|
|
739
|
+
logFilePath: t.logFilePath,
|
|
740
740
|
message: "REQUEST",
|
|
741
741
|
data: { name: o, args: a }
|
|
742
742
|
});
|
|
743
743
|
const c = await n(...a);
|
|
744
744
|
return await ie({
|
|
745
|
-
logFilePath:
|
|
745
|
+
logFilePath: t.logFilePath,
|
|
746
746
|
message: "RESPONSE",
|
|
747
747
|
data: c
|
|
748
748
|
}), {
|
|
@@ -754,35 +754,116 @@ function Jr(t, r) {
|
|
|
754
754
|
]
|
|
755
755
|
};
|
|
756
756
|
};
|
|
757
|
-
return
|
|
757
|
+
return r.registerTool(
|
|
758
758
|
o,
|
|
759
759
|
e,
|
|
760
760
|
i
|
|
761
761
|
);
|
|
762
762
|
};
|
|
763
763
|
}
|
|
764
|
-
function Wr(
|
|
765
|
-
return
|
|
764
|
+
function Wr(r) {
|
|
765
|
+
return r.match(/^[/\\]?[^/\\]+/)[0];
|
|
766
766
|
}
|
|
767
|
-
function Kr(
|
|
768
|
-
return Wr(
|
|
767
|
+
function Kr(r, t) {
|
|
768
|
+
return Wr(r) + "|" + t;
|
|
769
769
|
}
|
|
770
|
-
function Hr(
|
|
771
|
-
return
|
|
770
|
+
function Hr(r) {
|
|
771
|
+
return r.endsWith(":") && (r += "/"), k.resolve(r);
|
|
772
|
+
}
|
|
773
|
+
class Qr {
|
|
774
|
+
_bigStat;
|
|
775
|
+
constructor(t) {
|
|
776
|
+
this._bigStat = t;
|
|
777
|
+
}
|
|
778
|
+
get ino() {
|
|
779
|
+
return this._bigStat.ino;
|
|
780
|
+
}
|
|
781
|
+
get size() {
|
|
782
|
+
return Number(this._bigStat.size);
|
|
783
|
+
}
|
|
784
|
+
get mtimeMs() {
|
|
785
|
+
return Number(this._bigStat.mtimeMs);
|
|
786
|
+
}
|
|
787
|
+
get atimeMs() {
|
|
788
|
+
return Number(this._bigStat.atimeMs);
|
|
789
|
+
}
|
|
790
|
+
get ctimeMs() {
|
|
791
|
+
return Number(this._bigStat.ctimeMs);
|
|
792
|
+
}
|
|
793
|
+
get birthtimeMs() {
|
|
794
|
+
return Number(this._bigStat.birthtimeMs);
|
|
795
|
+
}
|
|
796
|
+
get blksize() {
|
|
797
|
+
return Number(this._bigStat.blksize);
|
|
798
|
+
}
|
|
799
|
+
get blocks() {
|
|
800
|
+
return Number(this._bigStat.blocks);
|
|
801
|
+
}
|
|
802
|
+
get dev() {
|
|
803
|
+
return Number(this._bigStat.dev);
|
|
804
|
+
}
|
|
805
|
+
get gid() {
|
|
806
|
+
return Number(this._bigStat.gid);
|
|
807
|
+
}
|
|
808
|
+
get mode() {
|
|
809
|
+
return Number(this._bigStat.mode);
|
|
810
|
+
}
|
|
811
|
+
get nlink() {
|
|
812
|
+
return Number(this._bigStat.nlink);
|
|
813
|
+
}
|
|
814
|
+
get rdev() {
|
|
815
|
+
return Number(this._bigStat.rdev);
|
|
816
|
+
}
|
|
817
|
+
get uid() {
|
|
818
|
+
return Number(this._bigStat.uid);
|
|
819
|
+
}
|
|
820
|
+
get atime() {
|
|
821
|
+
return this._bigStat.atime;
|
|
822
|
+
}
|
|
823
|
+
get mtime() {
|
|
824
|
+
return this._bigStat.mtime;
|
|
825
|
+
}
|
|
826
|
+
get ctime() {
|
|
827
|
+
return this._bigStat.ctime;
|
|
828
|
+
}
|
|
829
|
+
get birthtime() {
|
|
830
|
+
return this._bigStat.birthtime;
|
|
831
|
+
}
|
|
832
|
+
isFile() {
|
|
833
|
+
return this._bigStat.isFile();
|
|
834
|
+
}
|
|
835
|
+
isDirectory() {
|
|
836
|
+
return this._bigStat.isDirectory();
|
|
837
|
+
}
|
|
838
|
+
isSymbolicLink() {
|
|
839
|
+
return this._bigStat.isSymbolicLink();
|
|
840
|
+
}
|
|
841
|
+
isBlockDevice() {
|
|
842
|
+
return this._bigStat.isBlockDevice();
|
|
843
|
+
}
|
|
844
|
+
isCharacterDevice() {
|
|
845
|
+
return this._bigStat.isCharacterDevice();
|
|
846
|
+
}
|
|
847
|
+
isFIFO() {
|
|
848
|
+
return this._bigStat.isFIFO();
|
|
849
|
+
}
|
|
850
|
+
isSocket() {
|
|
851
|
+
return this._bigStat.isSocket();
|
|
852
|
+
}
|
|
772
853
|
}
|
|
773
854
|
const Se = new rr(ir.cpus().length);
|
|
774
|
-
function Be(
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
),
|
|
779
|
-
}
|
|
780
|
-
const
|
|
781
|
-
return
|
|
855
|
+
function Be(r, t) {
|
|
856
|
+
r.totalSize += t.totalSize, r.maxFileDateModified = Math.max(
|
|
857
|
+
r.maxFileDateModified,
|
|
858
|
+
t.maxFileDateModified
|
|
859
|
+
), r.countFiles += t.countFiles, r.countDirs += t.countDirs, r.countLinks += t.countLinks;
|
|
860
|
+
}
|
|
861
|
+
const Yr = function(t) {
|
|
862
|
+
return t.code === "ENOENT";
|
|
782
863
|
};
|
|
783
|
-
function xt(
|
|
784
|
-
const
|
|
785
|
-
if (!
|
|
864
|
+
function xt(r) {
|
|
865
|
+
const t = r.paths;
|
|
866
|
+
if (!t || t.length === 0)
|
|
786
867
|
return Promise.resolve({
|
|
787
868
|
totalSize: 0,
|
|
788
869
|
maxFileDateModified: 0,
|
|
@@ -790,9 +871,9 @@ function xt(t) {
|
|
|
790
871
|
countDirs: 0,
|
|
791
872
|
countLinks: 0
|
|
792
873
|
});
|
|
793
|
-
const s =
|
|
874
|
+
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;
|
|
794
875
|
async function d(h) {
|
|
795
|
-
if (!(i && await i(h)) && !
|
|
876
|
+
if (!(i && await i(h)) && !Yr(h))
|
|
796
877
|
throw h;
|
|
797
878
|
}
|
|
798
879
|
function p(h) {
|
|
@@ -806,152 +887,159 @@ function xt(t) {
|
|
|
806
887
|
countDirs: 0,
|
|
807
888
|
countLinks: 0
|
|
808
889
|
};
|
|
809
|
-
function w(
|
|
890
|
+
function w($, T) {
|
|
810
891
|
if (p(T.totalSize)) {
|
|
811
|
-
const
|
|
812
|
-
l?.handleLog ? l.handleLog(
|
|
892
|
+
const x = `${T.totalSize.toLocaleString("en-US").replace(/,/g, " ").padStart(19)}: ${$}`;
|
|
893
|
+
l?.handleLog ? l.handleLog(x) : console.log(x);
|
|
813
894
|
}
|
|
814
895
|
}
|
|
815
|
-
async function
|
|
896
|
+
async function I($, T, S, x) {
|
|
816
897
|
return u ? await V({
|
|
817
898
|
pool: n,
|
|
818
899
|
func: async () => {
|
|
819
900
|
try {
|
|
820
901
|
return await u({
|
|
821
902
|
level: s,
|
|
822
|
-
path:
|
|
903
|
+
path: $,
|
|
823
904
|
stat: T,
|
|
824
|
-
itemStat:
|
|
905
|
+
itemStat: S,
|
|
825
906
|
totalStat: y,
|
|
826
907
|
abortSignal: g
|
|
827
908
|
});
|
|
828
|
-
} catch (
|
|
829
|
-
return await d(
|
|
909
|
+
} catch (C) {
|
|
910
|
+
return await d(C), !1;
|
|
830
911
|
}
|
|
831
912
|
},
|
|
832
913
|
count: 1,
|
|
833
|
-
priority:
|
|
914
|
+
priority: x,
|
|
834
915
|
abortSignal: g
|
|
835
916
|
}) : !0;
|
|
836
917
|
}
|
|
837
|
-
async function E(
|
|
838
|
-
|
|
839
|
-
const
|
|
918
|
+
async function E($, T, S, x) {
|
|
919
|
+
x || (x = $);
|
|
920
|
+
const C = await V({
|
|
840
921
|
pool: n,
|
|
841
|
-
func: () =>
|
|
922
|
+
func: async () => {
|
|
923
|
+
try {
|
|
924
|
+
const v = await U.promises.lstat($, { bigint: !0 });
|
|
925
|
+
return new Qr(v);
|
|
926
|
+
} catch (v) {
|
|
927
|
+
return await d(v);
|
|
928
|
+
}
|
|
929
|
+
},
|
|
842
930
|
count: 1,
|
|
843
931
|
priority: X(T, X(1, a)),
|
|
844
932
|
abortSignal: g
|
|
845
933
|
});
|
|
846
|
-
if (!
|
|
934
|
+
if (!C || !S && C.isFile())
|
|
847
935
|
return null;
|
|
848
|
-
const P = Kr(
|
|
936
|
+
const P = Kr($, C.ino);
|
|
849
937
|
if (o.has(P))
|
|
850
938
|
return null;
|
|
851
939
|
o.add(P);
|
|
852
940
|
let O = {
|
|
853
|
-
totalSize:
|
|
854
|
-
maxFileDateModified:
|
|
941
|
+
totalSize: C.size,
|
|
942
|
+
maxFileDateModified: C.isDirectory() ? 0 : C.mtimeMs,
|
|
855
943
|
countFiles: 0,
|
|
856
944
|
countDirs: 0,
|
|
857
945
|
countLinks: 0
|
|
858
946
|
};
|
|
859
|
-
const
|
|
947
|
+
const M = X(
|
|
860
948
|
T,
|
|
861
|
-
X(
|
|
949
|
+
X(C.isDirectory() ? 2 : 3, a)
|
|
862
950
|
);
|
|
863
|
-
if (
|
|
951
|
+
if (C.isSymbolicLink()) {
|
|
864
952
|
if (c) {
|
|
865
|
-
const
|
|
953
|
+
const v = await V({
|
|
866
954
|
pool: n,
|
|
867
|
-
func: () =>
|
|
955
|
+
func: () => U.promises.readlink($).catch(d).then((N) => N ?? null),
|
|
868
956
|
count: 1,
|
|
869
|
-
priority:
|
|
957
|
+
priority: M,
|
|
870
958
|
abortSignal: g
|
|
871
959
|
});
|
|
872
|
-
if (
|
|
873
|
-
const N = k.isAbsolute(
|
|
960
|
+
if (v) {
|
|
961
|
+
const N = k.isAbsolute(v) ? v : k.resolve(k.dirname(x), v), R = await E(
|
|
874
962
|
N,
|
|
875
963
|
T,
|
|
876
|
-
|
|
877
|
-
|
|
964
|
+
S,
|
|
965
|
+
x
|
|
878
966
|
);
|
|
879
967
|
R && (O = R);
|
|
880
968
|
}
|
|
881
969
|
}
|
|
882
|
-
return (
|
|
883
|
-
|
|
884
|
-
|
|
970
|
+
return (S || O.countFiles + O.countDirs + O.countLinks >= 1) && (O.countLinks += 1, await I(
|
|
971
|
+
x,
|
|
972
|
+
C,
|
|
885
973
|
O,
|
|
886
|
-
|
|
887
|
-
) && (Be(y, O), w(
|
|
888
|
-
} else if (
|
|
889
|
-
const
|
|
974
|
+
M
|
|
975
|
+
) && (Be(y, O), w(x, O))), O;
|
|
976
|
+
} else if (C.isDirectory()) {
|
|
977
|
+
const v = await V({
|
|
890
978
|
pool: n,
|
|
891
|
-
func: () =>
|
|
979
|
+
func: () => U.promises.readdir($).catch(d),
|
|
892
980
|
count: 1,
|
|
893
981
|
priority: a,
|
|
894
982
|
abortSignal: g
|
|
895
983
|
});
|
|
896
|
-
if (
|
|
897
|
-
for (let N = 0, R =
|
|
898
|
-
|
|
984
|
+
if (v) {
|
|
985
|
+
for (let N = 0, R = v.length; N < R; N++)
|
|
986
|
+
v[N] = k.join(x, v[N]);
|
|
899
987
|
O = await xt({
|
|
900
|
-
...
|
|
901
|
-
paths:
|
|
988
|
+
...r,
|
|
989
|
+
paths: v,
|
|
902
990
|
abortSignal: g,
|
|
903
|
-
priority:
|
|
991
|
+
priority: M,
|
|
904
992
|
level: s + 1,
|
|
905
993
|
walkedIds: o
|
|
906
994
|
});
|
|
907
995
|
}
|
|
908
996
|
}
|
|
909
|
-
return (
|
|
910
|
-
|
|
911
|
-
|
|
997
|
+
return (S || O.countFiles + O.countDirs + O.countLinks >= 1) && (C.isDirectory() ? O.countDirs += 1 : C.isFile() && (O.countFiles += 1), await I(
|
|
998
|
+
x,
|
|
999
|
+
C,
|
|
912
1000
|
O,
|
|
913
|
-
|
|
914
|
-
) && (Be(y, O), w(
|
|
1001
|
+
M
|
|
1002
|
+
) && (Be(y, O), w(x, O))), O;
|
|
915
1003
|
}
|
|
916
1004
|
const b = [];
|
|
917
|
-
for (let
|
|
918
|
-
const
|
|
919
|
-
|
|
1005
|
+
for (let $ = 0, T = t.length; $ < T; $++) {
|
|
1006
|
+
const S = Hr(t[$]), x = f ? f(S) : !0;
|
|
1007
|
+
x !== !1 && b.push(E(S, $, x));
|
|
920
1008
|
}
|
|
921
1009
|
return await Promise.all(b), y;
|
|
922
1010
|
});
|
|
923
1011
|
}
|
|
924
|
-
function It(
|
|
925
|
-
return xt(
|
|
1012
|
+
function It(r) {
|
|
1013
|
+
return xt(r);
|
|
926
1014
|
}
|
|
927
|
-
function
|
|
928
|
-
if (!
|
|
929
|
-
return
|
|
930
|
-
const s =
|
|
931
|
-
s && (
|
|
932
|
-
const o =
|
|
933
|
-
return o && (
|
|
1015
|
+
function Vr(r, t) {
|
|
1016
|
+
if (!t || t === ".")
|
|
1017
|
+
return r;
|
|
1018
|
+
const s = r.startsWith("^");
|
|
1019
|
+
s && (r = r.substring(1));
|
|
1020
|
+
const o = r.startsWith("!");
|
|
1021
|
+
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;
|
|
934
1022
|
}
|
|
935
|
-
function
|
|
936
|
-
const
|
|
937
|
-
return
|
|
1023
|
+
function Zr(r) {
|
|
1024
|
+
const t = r.startsWith("!");
|
|
1025
|
+
return t && (r = r.substring(1)), !r.startsWith("/") && !r.startsWith("**") && !r.startsWith("../") && (r = `**/${r}`), t && (r = "!" + r), r;
|
|
938
1026
|
}
|
|
939
|
-
function Le(
|
|
940
|
-
return "^" +
|
|
1027
|
+
function Le(r) {
|
|
1028
|
+
return "^" + r;
|
|
941
1029
|
}
|
|
942
|
-
async function
|
|
943
|
-
const s = (await
|
|
1030
|
+
async function Xr(r) {
|
|
1031
|
+
const s = (await U.promises.readFile(r, "utf-8")).split(`
|
|
944
1032
|
`), o = [];
|
|
945
1033
|
return s.forEach((e) => {
|
|
946
1034
|
e = e.trim(), !(!e || e.startsWith("#")) && o.push(e);
|
|
947
1035
|
}), o;
|
|
948
1036
|
}
|
|
949
|
-
async function $t(
|
|
950
|
-
const
|
|
951
|
-
if (!
|
|
1037
|
+
async function $t(r) {
|
|
1038
|
+
const t = r.rootDir ?? ".", s = [];
|
|
1039
|
+
if (!r.globs?.length)
|
|
952
1040
|
return s;
|
|
953
1041
|
const o = [];
|
|
954
|
-
return
|
|
1042
|
+
return r.globs.forEach((e) => {
|
|
955
1043
|
e.value && (e.valueType === "file-contains-patterns" ? o.push(e) : e.valueType === "pattern" && s.push(e.exclude ? Le(e.value) : e.value));
|
|
956
1044
|
}), o.length && await Promise.all(
|
|
957
1045
|
o.map(async (e) => {
|
|
@@ -959,9 +1047,9 @@ async function $t(t) {
|
|
|
959
1047
|
pool: Se,
|
|
960
1048
|
count: 1,
|
|
961
1049
|
func: async () => {
|
|
962
|
-
const n = k.resolve(
|
|
1050
|
+
const n = k.resolve(t, e.value), i = await Xr(n), a = k.relative(t, k.dirname(n));
|
|
963
1051
|
i.forEach((c) => {
|
|
964
|
-
c =
|
|
1052
|
+
c = Zr(c), c = Vr(c, a), s.push(e.exclude ? Le(c) : c);
|
|
965
1053
|
});
|
|
966
1054
|
}
|
|
967
1055
|
});
|
|
@@ -969,12 +1057,12 @@ async function $t(t) {
|
|
|
969
1057
|
), s;
|
|
970
1058
|
}
|
|
971
1059
|
function Mt({
|
|
972
|
-
globs:
|
|
973
|
-
rootDir:
|
|
1060
|
+
globs: r,
|
|
1061
|
+
rootDir: t,
|
|
974
1062
|
noCase: s
|
|
975
1063
|
}) {
|
|
976
1064
|
const o = [];
|
|
977
|
-
return
|
|
1065
|
+
return r.forEach((e) => {
|
|
978
1066
|
e = H(e).trim();
|
|
979
1067
|
const n = e.startsWith("^");
|
|
980
1068
|
n && (e = e.substring(1).trim());
|
|
@@ -984,7 +1072,7 @@ function Mt({
|
|
|
984
1072
|
`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.`
|
|
985
1073
|
);
|
|
986
1074
|
e.startsWith("/") && (e = "." + e);
|
|
987
|
-
const a = H(
|
|
1075
|
+
const a = H(t ? k.resolve(t, e) : e);
|
|
988
1076
|
if (!a)
|
|
989
1077
|
return;
|
|
990
1078
|
let c;
|
|
@@ -1016,61 +1104,61 @@ function Mt({
|
|
|
1016
1104
|
return a ? !1 : i;
|
|
1017
1105
|
};
|
|
1018
1106
|
}
|
|
1019
|
-
async function
|
|
1020
|
-
const
|
|
1021
|
-
|
|
1107
|
+
async function es(r) {
|
|
1108
|
+
const t = r.rootDir ?? ".", s = [], o = {};
|
|
1109
|
+
r.result.countFiles && (o.countFiles = 0), r.result.size && (o.size = 0);
|
|
1022
1110
|
const e = await $t({
|
|
1023
|
-
rootDir:
|
|
1024
|
-
globs:
|
|
1111
|
+
rootDir: t,
|
|
1112
|
+
globs: r.globs
|
|
1025
1113
|
});
|
|
1026
1114
|
return await It({
|
|
1027
|
-
paths: [
|
|
1115
|
+
paths: [t],
|
|
1028
1116
|
walkLinks: !0,
|
|
1029
1117
|
matchPath: Mt({
|
|
1030
1118
|
globs: e,
|
|
1031
|
-
rootDir:
|
|
1119
|
+
rootDir: t,
|
|
1032
1120
|
noCase: !0
|
|
1033
1121
|
}),
|
|
1034
1122
|
handlePath: async ({ path: n, stat: i, itemStat: a }) => {
|
|
1035
|
-
const c = k.relative(
|
|
1123
|
+
const c = k.relative(t, n), l = i.isDirectory(), u = i.isFile();
|
|
1036
1124
|
if (!l && !u)
|
|
1037
1125
|
return !0;
|
|
1038
1126
|
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 = {
|
|
1039
1127
|
path: f,
|
|
1040
1128
|
type: d
|
|
1041
1129
|
};
|
|
1042
|
-
if (
|
|
1043
|
-
const [w,
|
|
1044
|
-
if (w != null && p < w ||
|
|
1130
|
+
if (r.result.dateModified && (y.dateModified = p), r.result.size && (y.size = h), r.result.countFiles && (y.countFiles = g), r.dateModified && p != null) {
|
|
1131
|
+
const [w, I] = r.dateModified;
|
|
1132
|
+
if (w != null && p < w || I != null && p > I)
|
|
1045
1133
|
return !1;
|
|
1046
1134
|
}
|
|
1047
|
-
if (
|
|
1048
|
-
const [w,
|
|
1049
|
-
if (w != null && h < w ||
|
|
1135
|
+
if (r.totalSize && h != null) {
|
|
1136
|
+
const [w, I] = r.totalSize;
|
|
1137
|
+
if (w != null && h < w || I != null && h > I)
|
|
1050
1138
|
return !1;
|
|
1051
1139
|
}
|
|
1052
|
-
return d === "file" && (o.countFiles = (o.countFiles ?? 0) + 1), d === "file" && h != null && (o.size = (o.size ?? 0) + h), p != null && (o.dateModified == null || p > o.dateModified) && (o.dateModified = p), l && !
|
|
1140
|
+
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;
|
|
1053
1141
|
}
|
|
1054
1142
|
}), { items: s, totals: o };
|
|
1055
1143
|
}
|
|
1056
1144
|
const Ae = ["B", "KB", "MB", "GB", "TB"], ze = 1024;
|
|
1057
|
-
function
|
|
1058
|
-
if (
|
|
1059
|
-
let
|
|
1060
|
-
for (;
|
|
1061
|
-
|
|
1062
|
-
return `${s === 0 ?
|
|
1063
|
-
}
|
|
1064
|
-
function
|
|
1065
|
-
const s = Date.now() -
|
|
1145
|
+
function _e(r) {
|
|
1146
|
+
if (r == null) return "-";
|
|
1147
|
+
let t = r ?? 0, s = 0;
|
|
1148
|
+
for (; t >= ze && s < Ae.length - 1; )
|
|
1149
|
+
t /= ze, s++;
|
|
1150
|
+
return `${s === 0 ? t.toString() : t.toFixed(2)}${Ae[s]}`;
|
|
1151
|
+
}
|
|
1152
|
+
function Ue(r) {
|
|
1153
|
+
const s = Date.now() - r;
|
|
1066
1154
|
if (s < 0) return "0s";
|
|
1067
1155
|
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);
|
|
1068
1156
|
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`;
|
|
1069
1157
|
}
|
|
1070
|
-
function
|
|
1071
|
-
return
|
|
1072
|
-
for (let e = 0, n =
|
|
1073
|
-
const i =
|
|
1158
|
+
function ts(r, t) {
|
|
1159
|
+
return t?.length ? [...r].sort((s, o) => {
|
|
1160
|
+
for (let e = 0, n = t.length; e < n; e++) {
|
|
1161
|
+
const i = t[e];
|
|
1074
1162
|
let a, c;
|
|
1075
1163
|
switch (i.field) {
|
|
1076
1164
|
case "type":
|
|
@@ -1101,10 +1189,10 @@ function es(t, r) {
|
|
|
1101
1189
|
return i.desc ? -l : l;
|
|
1102
1190
|
}
|
|
1103
1191
|
return 0;
|
|
1104
|
-
}) :
|
|
1192
|
+
}) : r;
|
|
1105
1193
|
}
|
|
1106
|
-
function
|
|
1107
|
-
const s =
|
|
1194
|
+
function rs(r, t) {
|
|
1195
|
+
const s = ts(r.items, t.sort ?? []), o = t.fields && t.fields.length > 0 ? t.fields : [];
|
|
1108
1196
|
let e = "";
|
|
1109
1197
|
if (s.length > 0 && o.length > 0) {
|
|
1110
1198
|
for (let n = 0, i = o.length; n < i; n++) {
|
|
@@ -1135,10 +1223,10 @@ function ts(t, r) {
|
|
|
1135
1223
|
const u = o[c];
|
|
1136
1224
|
switch (c > 0 && (e += " | "), u) {
|
|
1137
1225
|
case "dateModified":
|
|
1138
|
-
e += a.dateModified ?
|
|
1226
|
+
e += a.dateModified ? Ue(a.dateModified) : "-";
|
|
1139
1227
|
break;
|
|
1140
1228
|
case "size":
|
|
1141
|
-
e +=
|
|
1229
|
+
e += _e(a.size);
|
|
1142
1230
|
break;
|
|
1143
1231
|
case "type":
|
|
1144
1232
|
e += a.type;
|
|
@@ -1157,24 +1245,24 @@ function ts(t, r) {
|
|
|
1157
1245
|
e.length > 0 && (e += `
|
|
1158
1246
|
---
|
|
1159
1247
|
`);
|
|
1160
|
-
const n =
|
|
1161
|
-
e += `Totals: ${
|
|
1248
|
+
const n = _e(r.totals.size ?? 0), i = r.totals.dateModified ? `, last modified ${Ue(r.totals.dateModified)} ago` : "";
|
|
1249
|
+
e += `Totals: ${r.totals.countFiles ?? 0} files in dirs, ${n}${i}`;
|
|
1162
1250
|
}
|
|
1163
1251
|
return e;
|
|
1164
1252
|
}
|
|
1165
|
-
const
|
|
1166
|
-
version:
|
|
1167
|
-
},
|
|
1168
|
-
function
|
|
1169
|
-
const
|
|
1253
|
+
const ss = "5.0.2", os = {
|
|
1254
|
+
version: ss
|
|
1255
|
+
}, Ko = "Project Tools", Ho = "project-tools", Qo = os.version, Yo = "d00f70240703039df14c76176a055bce6b5484d2b552ba2c89820f03b8e5e60d", je = 25e3;
|
|
1256
|
+
function qe(r) {
|
|
1257
|
+
const t = r.match(
|
|
1170
1258
|
/^\s*(\d+(?:\.\d+)?)\s*([smhdwMY]|sec(onds?)?|min(utes?)?|hours?|days?|weeks?|months?|years?)\s*$/i
|
|
1171
1259
|
);
|
|
1172
|
-
if (!
|
|
1260
|
+
if (!t)
|
|
1173
1261
|
throw new Error(
|
|
1174
|
-
`Invalid time ago format: "${
|
|
1262
|
+
`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).`
|
|
1175
1263
|
);
|
|
1176
|
-
const s = parseFloat(
|
|
1177
|
-
let o =
|
|
1264
|
+
const s = parseFloat(t[1]);
|
|
1265
|
+
let o = t[2];
|
|
1178
1266
|
switch (o !== "M" && (o = o.toLowerCase(), o.startsWith("month") ? o = "M" : o.length > 1 && (o = o[0])), o) {
|
|
1179
1267
|
case "s":
|
|
1180
1268
|
return s * 1e3;
|
|
@@ -1196,13 +1284,13 @@ function _e(t) {
|
|
|
1196
1284
|
);
|
|
1197
1285
|
}
|
|
1198
1286
|
}
|
|
1199
|
-
function Ge(
|
|
1200
|
-
const
|
|
1201
|
-
if (!
|
|
1287
|
+
function Ge(r) {
|
|
1288
|
+
const t = r.match(/^\s*(\d+(?:\.\d+)?)\s*(B|KB|MB|GB|TB)\s*$/i);
|
|
1289
|
+
if (!t)
|
|
1202
1290
|
throw new Error(
|
|
1203
|
-
`Invalid size format: "${
|
|
1291
|
+
`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.`
|
|
1204
1292
|
);
|
|
1205
|
-
const s = parseFloat(
|
|
1293
|
+
const s = parseFloat(t[1]), o = t[2].toUpperCase();
|
|
1206
1294
|
switch (o) {
|
|
1207
1295
|
case "B":
|
|
1208
1296
|
return s;
|
|
@@ -1259,10 +1347,10 @@ const Tt = m.object({
|
|
|
1259
1347
|
'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'
|
|
1260
1348
|
)
|
|
1261
1349
|
});
|
|
1262
|
-
async function
|
|
1350
|
+
async function ns(r, t) {
|
|
1263
1351
|
let s;
|
|
1264
1352
|
try {
|
|
1265
|
-
s = Tt.parse(
|
|
1353
|
+
s = Tt.parse(r);
|
|
1266
1354
|
} catch (y) {
|
|
1267
1355
|
return {
|
|
1268
1356
|
error: F(y)
|
|
@@ -1293,7 +1381,7 @@ async function os(t, r) {
|
|
|
1293
1381
|
}) ?? null;
|
|
1294
1382
|
(!d || d.length === 0) && (d = [{ field: "path", desc: !1 }]);
|
|
1295
1383
|
const p = d?.map((y) => y.field) || [], h = be(
|
|
1296
|
-
|
|
1384
|
+
t.workingDir,
|
|
1297
1385
|
s.relativeRootDir
|
|
1298
1386
|
);
|
|
1299
1387
|
if ("error" in h)
|
|
@@ -1301,55 +1389,55 @@ async function os(t, r) {
|
|
|
1301
1389
|
const g = h.path;
|
|
1302
1390
|
try {
|
|
1303
1391
|
try {
|
|
1304
|
-
await
|
|
1305
|
-
} catch (
|
|
1306
|
-
if (
|
|
1392
|
+
await U.promises.access(g, U.constants.F_OK);
|
|
1393
|
+
} catch (x) {
|
|
1394
|
+
if (x.code === "ENOENT")
|
|
1307
1395
|
return {
|
|
1308
1396
|
error: `Directory does not exist: "${g}". Verify the path is correct and accessible. If using rootDir parameter, ensure it exists relative to the current working directory. Use fs-list without rootDir to list the current directory, or check parent directories first.`
|
|
1309
1397
|
};
|
|
1310
|
-
throw
|
|
1398
|
+
throw x;
|
|
1311
1399
|
}
|
|
1312
|
-
const y = o && o.length > 0 ? o.map((
|
|
1313
|
-
value:
|
|
1400
|
+
const y = o && o.length > 0 ? o.map((x) => ({
|
|
1401
|
+
value: x,
|
|
1314
1402
|
valueType: "pattern",
|
|
1315
1403
|
exclude: !1
|
|
1316
|
-
})) : [{ value: "**", valueType: "pattern", exclude: !1 }], w =
|
|
1404
|
+
})) : [{ value: "**", valueType: "pattern", exclude: !1 }], w = t.globsExclude || [], I = [...y, ...w], E = {
|
|
1317
1405
|
files: e ?? !1,
|
|
1318
1406
|
dirs: n ?? !1,
|
|
1319
1407
|
dateModified: f.includes("dateModified") || p.includes("dateModified"),
|
|
1320
1408
|
size: f.includes("size") || p.includes("size"),
|
|
1321
1409
|
countFiles: f.includes("countFiles") || p.includes("countFiles")
|
|
1322
1410
|
};
|
|
1323
|
-
let b = null,
|
|
1411
|
+
let b = null, $ = null;
|
|
1324
1412
|
if (a || c)
|
|
1325
1413
|
try {
|
|
1326
|
-
const
|
|
1327
|
-
b = [
|
|
1328
|
-
} catch (
|
|
1414
|
+
const x = Date.now(), C = c ? x - qe(c) : null, P = a ? x - qe(a) : null;
|
|
1415
|
+
b = [C, P];
|
|
1416
|
+
} catch (x) {
|
|
1329
1417
|
return {
|
|
1330
|
-
error:
|
|
1418
|
+
error: x instanceof Error ? x.message : "Unknown error parsing time ago filter"
|
|
1331
1419
|
};
|
|
1332
1420
|
}
|
|
1333
1421
|
if (l || u)
|
|
1334
1422
|
try {
|
|
1335
|
-
const
|
|
1336
|
-
|
|
1337
|
-
} catch (
|
|
1423
|
+
const x = l ? Ge(l) : null, C = u ? Ge(u) : null;
|
|
1424
|
+
$ = [x, C];
|
|
1425
|
+
} catch (x) {
|
|
1338
1426
|
return {
|
|
1339
|
-
error:
|
|
1427
|
+
error: x instanceof Error ? x.message : "Unknown error parsing size filter"
|
|
1340
1428
|
};
|
|
1341
1429
|
}
|
|
1342
|
-
const T = await
|
|
1430
|
+
const T = await es({
|
|
1343
1431
|
rootDir: g || null,
|
|
1344
|
-
globs:
|
|
1432
|
+
globs: I,
|
|
1345
1433
|
result: E,
|
|
1346
1434
|
dateModified: b,
|
|
1347
|
-
totalSize:
|
|
1435
|
+
totalSize: $
|
|
1348
1436
|
});
|
|
1349
|
-
return T.items.length >
|
|
1350
|
-
error: `Number of paths (${T.items.length}) exceeds maximum allowed (${
|
|
1437
|
+
return T.items.length > je ? {
|
|
1438
|
+
error: `Number of paths (${T.items.length}) exceeds maximum allowed (${je}). Consider using more specific glob patterns or filters to reduce the result set.`
|
|
1351
1439
|
} : {
|
|
1352
|
-
output:
|
|
1440
|
+
output: rs(T, {
|
|
1353
1441
|
sort: d,
|
|
1354
1442
|
fields: f,
|
|
1355
1443
|
totals: !0
|
|
@@ -1359,8 +1447,8 @@ async function os(t, r) {
|
|
|
1359
1447
|
return { error: y instanceof Error ? y.message : "Unknown error" };
|
|
1360
1448
|
}
|
|
1361
1449
|
}
|
|
1362
|
-
function
|
|
1363
|
-
|
|
1450
|
+
function is(r, t) {
|
|
1451
|
+
r(
|
|
1364
1452
|
"fs-list",
|
|
1365
1453
|
{
|
|
1366
1454
|
title: "List Files and Directories",
|
|
@@ -1368,7 +1456,7 @@ function ns(t, r) {
|
|
|
1368
1456
|
inputSchema: Tt.shape
|
|
1369
1457
|
},
|
|
1370
1458
|
async (s) => {
|
|
1371
|
-
const o = await
|
|
1459
|
+
const o = await ns(s, t);
|
|
1372
1460
|
return o.error ? `Method: fs-list(${JSON.stringify(s)})
|
|
1373
1461
|
❌ Error: ${o.error}` : `Method: fs-list(${JSON.stringify(s)})
|
|
1374
1462
|
${o.output || JSON.stringify(o, null, 2)}`;
|
|
@@ -1376,27 +1464,27 @@ ${o.output || JSON.stringify(o, null, 2)}`;
|
|
|
1376
1464
|
);
|
|
1377
1465
|
}
|
|
1378
1466
|
const ue = /* @__PURE__ */ new Map();
|
|
1379
|
-
let
|
|
1380
|
-
function
|
|
1381
|
-
return `${++
|
|
1467
|
+
let as = 0;
|
|
1468
|
+
function ls() {
|
|
1469
|
+
return `${++as}-${Math.random().toString(36).slice(2)}`;
|
|
1382
1470
|
}
|
|
1383
|
-
function Z(
|
|
1384
|
-
return ue.has(
|
|
1471
|
+
function Z(r) {
|
|
1472
|
+
return ue.has(r) || ue.set(r, {
|
|
1385
1473
|
fsSnapshotQueries: /* @__PURE__ */ new Map(),
|
|
1386
1474
|
fsSnapshots: /* @__PURE__ */ new Map(),
|
|
1387
1475
|
preparedReplace: null
|
|
1388
|
-
}), ue.get(
|
|
1476
|
+
}), ue.get(r);
|
|
1389
1477
|
}
|
|
1390
|
-
function Je(
|
|
1391
|
-
const
|
|
1478
|
+
function Je(r) {
|
|
1479
|
+
const t = r.match(
|
|
1392
1480
|
/^\s*(\d+(?:\.\d+)?)\s*([smhdwMY]|sec(onds?)?|min(utes?)?|hours?|days?|weeks?|months?|years?)\s*$/i
|
|
1393
1481
|
);
|
|
1394
|
-
if (!
|
|
1482
|
+
if (!t)
|
|
1395
1483
|
throw new Error(
|
|
1396
|
-
`Invalid time ago format: "${
|
|
1484
|
+
`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).`
|
|
1397
1485
|
);
|
|
1398
|
-
const s = parseFloat(
|
|
1399
|
-
let o =
|
|
1486
|
+
const s = parseFloat(t[1]);
|
|
1487
|
+
let o = t[2];
|
|
1400
1488
|
switch (o !== "M" && (o = o.toLowerCase(), o.startsWith("month") ? o = "M" : o.length > 1 && (o = o[0])), o) {
|
|
1401
1489
|
case "s":
|
|
1402
1490
|
return s * 1e3;
|
|
@@ -1418,13 +1506,13 @@ function Je(t) {
|
|
|
1418
1506
|
);
|
|
1419
1507
|
}
|
|
1420
1508
|
}
|
|
1421
|
-
function We(
|
|
1422
|
-
const
|
|
1423
|
-
if (!
|
|
1509
|
+
function We(r) {
|
|
1510
|
+
const t = r.match(/^\s*(\d+(?:\.\d+)?)\s*(B|KB|MB|GB|TB)\s*$/i);
|
|
1511
|
+
if (!t)
|
|
1424
1512
|
throw new Error(
|
|
1425
|
-
`Invalid size format: "${
|
|
1513
|
+
`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.`
|
|
1426
1514
|
);
|
|
1427
|
-
const s = parseFloat(
|
|
1515
|
+
const s = parseFloat(t[1]), o = t[2].toUpperCase();
|
|
1428
1516
|
switch (o) {
|
|
1429
1517
|
case "B":
|
|
1430
1518
|
return s;
|
|
@@ -1477,16 +1565,16 @@ const xe = m.object({
|
|
|
1477
1565
|
"countMatched",
|
|
1478
1566
|
"size",
|
|
1479
1567
|
"dateModified"
|
|
1480
|
-
].map((
|
|
1568
|
+
].map((r, t) => [r, t])
|
|
1481
1569
|
);
|
|
1482
|
-
function
|
|
1483
|
-
const s = Ke.get(
|
|
1570
|
+
function cs(r, t) {
|
|
1571
|
+
const s = Ke.get(r) ?? 1 / 0, o = Ke.get(t) ?? 1 / 0;
|
|
1484
1572
|
return s > o ? 1 : s < o ? -1 : 0;
|
|
1485
1573
|
}
|
|
1486
|
-
async function
|
|
1574
|
+
async function vt(r, t, s) {
|
|
1487
1575
|
let o;
|
|
1488
1576
|
try {
|
|
1489
|
-
o = xe.parse(
|
|
1577
|
+
o = xe.parse(r);
|
|
1490
1578
|
} catch (h) {
|
|
1491
1579
|
return {
|
|
1492
1580
|
error: F(h)
|
|
@@ -1506,7 +1594,7 @@ async function Ct(t, r, s) {
|
|
|
1506
1594
|
error: "Session ID is required"
|
|
1507
1595
|
};
|
|
1508
1596
|
const f = Z(s.sessionId), d = be(
|
|
1509
|
-
|
|
1597
|
+
t.workingDir,
|
|
1510
1598
|
o.relativeRootDir
|
|
1511
1599
|
);
|
|
1512
1600
|
if ("error" in d)
|
|
@@ -1514,47 +1602,47 @@ async function Ct(t, r, s) {
|
|
|
1514
1602
|
const p = d.path;
|
|
1515
1603
|
try {
|
|
1516
1604
|
try {
|
|
1517
|
-
await
|
|
1518
|
-
} catch (
|
|
1519
|
-
if (
|
|
1605
|
+
await U.promises.access(p, U.constants.F_OK);
|
|
1606
|
+
} catch (S) {
|
|
1607
|
+
if (S.code === "ENOENT")
|
|
1520
1608
|
return {
|
|
1521
1609
|
error: `Directory does not exist: "${p}". Verify the path is correct and accessible. If using rootDir parameter, ensure it exists relative to the current working directory. Use fs-snapshot-query-create without rootDir to snapshot the current directory, or check parent directories first.`
|
|
1522
1610
|
};
|
|
1523
|
-
throw
|
|
1611
|
+
throw S;
|
|
1524
1612
|
}
|
|
1525
|
-
const h = o.extraFields ? o.extraFields.map((
|
|
1526
|
-
h.includes("name") || h.push("name"), h.sort(
|
|
1527
|
-
const g = n && n.length > 0 ? n.map((
|
|
1528
|
-
value:
|
|
1613
|
+
const h = o.extraFields ? o.extraFields.map((S) => S === "lastModified" ? "dateModified" : S) : [];
|
|
1614
|
+
h.includes("name") || h.push("name"), h.sort(cs);
|
|
1615
|
+
const g = n && n.length > 0 ? n.map((S) => ({
|
|
1616
|
+
value: S,
|
|
1529
1617
|
valueType: "pattern",
|
|
1530
1618
|
exclude: !1
|
|
1531
|
-
})) : [{ value: "**", valueType: "pattern", exclude: !1 }], y =
|
|
1532
|
-
let
|
|
1619
|
+
})) : [{ value: "**", valueType: "pattern", exclude: !1 }], y = t.globsExclude || [], w = [...g, ...y];
|
|
1620
|
+
let I = null, E = null;
|
|
1533
1621
|
if (a || c)
|
|
1534
1622
|
try {
|
|
1535
|
-
const
|
|
1536
|
-
|
|
1537
|
-
} catch (
|
|
1623
|
+
const S = Date.now(), x = c ? S - Je(c) : null, C = a ? S - Je(a) : null;
|
|
1624
|
+
I = [x, C];
|
|
1625
|
+
} catch (S) {
|
|
1538
1626
|
return {
|
|
1539
|
-
error:
|
|
1627
|
+
error: S instanceof Error ? S.message : "Unknown error parsing time ago filter"
|
|
1540
1628
|
};
|
|
1541
1629
|
}
|
|
1542
1630
|
if (l || u)
|
|
1543
1631
|
try {
|
|
1544
|
-
const
|
|
1545
|
-
E = [
|
|
1546
|
-
} catch (
|
|
1632
|
+
const S = l ? We(l) : null, x = u ? We(u) : null;
|
|
1633
|
+
E = [S, x];
|
|
1634
|
+
} catch (S) {
|
|
1547
1635
|
return {
|
|
1548
|
-
error:
|
|
1636
|
+
error: S instanceof Error ? S.message : "Unknown error parsing size filter"
|
|
1549
1637
|
};
|
|
1550
1638
|
}
|
|
1551
|
-
const b = i ? i.includes("file") : !0,
|
|
1639
|
+
const b = i ? i.includes("file") : !0, $ = i ? i.includes("dir") : !0, T = {
|
|
1552
1640
|
name: e,
|
|
1553
1641
|
rootDir: p,
|
|
1554
1642
|
globs: w,
|
|
1555
1643
|
matchFiles: b,
|
|
1556
|
-
matchDirs:
|
|
1557
|
-
dateModified:
|
|
1644
|
+
matchDirs: $,
|
|
1645
|
+
dateModified: I,
|
|
1558
1646
|
totalSize: E,
|
|
1559
1647
|
fields: h
|
|
1560
1648
|
};
|
|
@@ -1567,8 +1655,8 @@ async function Ct(t, r, s) {
|
|
|
1567
1655
|
};
|
|
1568
1656
|
}
|
|
1569
1657
|
}
|
|
1570
|
-
function
|
|
1571
|
-
|
|
1658
|
+
function us(r, t) {
|
|
1659
|
+
r(
|
|
1572
1660
|
"fs-snapshot-query-create",
|
|
1573
1661
|
{
|
|
1574
1662
|
title: "Create Filesystem Snapshot Query",
|
|
@@ -1576,21 +1664,21 @@ function cs(t, r) {
|
|
|
1576
1664
|
inputSchema: xe.shape
|
|
1577
1665
|
},
|
|
1578
1666
|
async (s, o) => {
|
|
1579
|
-
const e = await
|
|
1667
|
+
const e = await vt(s, t, o);
|
|
1580
1668
|
return e.error != null ? `Method: fs-snapshot-query-create(${JSON.stringify(s)})
|
|
1581
1669
|
❌ Error: ${e.error}` : `Method: fs-snapshot-query-create(${JSON.stringify(s)})
|
|
1582
1670
|
✅ Filesystem snapshot query "${e.snapshotQuery.name}" created successfully`;
|
|
1583
1671
|
}
|
|
1584
1672
|
);
|
|
1585
1673
|
}
|
|
1586
|
-
function le(
|
|
1587
|
-
const { idToNode:
|
|
1674
|
+
function le(r) {
|
|
1675
|
+
const { idToNode: t, idToChildIds: s } = r, o = t.get(null);
|
|
1588
1676
|
if (o == null)
|
|
1589
1677
|
throw new Error(
|
|
1590
1678
|
"Impossible behavior: root node (id: null) not found in idToNode"
|
|
1591
1679
|
);
|
|
1592
1680
|
const e = /* @__PURE__ */ new Map();
|
|
1593
|
-
return
|
|
1681
|
+
return t.forEach((n, i) => {
|
|
1594
1682
|
if (n != null) {
|
|
1595
1683
|
if (e.has(n)) {
|
|
1596
1684
|
const a = e.get(n);
|
|
@@ -1602,18 +1690,18 @@ function le(t) {
|
|
|
1602
1690
|
}
|
|
1603
1691
|
}), {
|
|
1604
1692
|
root: o,
|
|
1605
|
-
getNode: (n) =>
|
|
1693
|
+
getNode: (n) => t.get(n) ?? null,
|
|
1606
1694
|
getId: (n) => e.get(n) ?? null,
|
|
1607
1695
|
getChilds: (n) => {
|
|
1608
1696
|
let i = e.get(n);
|
|
1609
1697
|
if (i == null)
|
|
1610
|
-
if (n ===
|
|
1698
|
+
if (n === t.get(null))
|
|
1611
1699
|
i = null;
|
|
1612
1700
|
else
|
|
1613
1701
|
throw new Error("Impossible behavior: node not found in idToNode");
|
|
1614
1702
|
const a = s.get(i);
|
|
1615
1703
|
return a == null ? null : a.map((c) => {
|
|
1616
|
-
const l =
|
|
1704
|
+
const l = t.get(c);
|
|
1617
1705
|
if (l == null)
|
|
1618
1706
|
throw new Error(
|
|
1619
1707
|
`Child node with id '${c}' not found in idToNode`
|
|
@@ -1623,22 +1711,22 @@ function le(t) {
|
|
|
1623
1711
|
}
|
|
1624
1712
|
};
|
|
1625
1713
|
}
|
|
1626
|
-
function
|
|
1714
|
+
function Ct(r, t, s) {
|
|
1627
1715
|
let o = null;
|
|
1628
|
-
for (let e = 0, n =
|
|
1629
|
-
const i =
|
|
1716
|
+
for (let e = 0, n = t.length; e < n; e++) {
|
|
1717
|
+
const i = t[e], a = r(i), c = a == null ? null : Ct(r, a, s), l = s(i, c);
|
|
1630
1718
|
l != null && (o == null && (o = []), o.push(l));
|
|
1631
1719
|
}
|
|
1632
1720
|
return o;
|
|
1633
1721
|
}
|
|
1634
|
-
function Et(
|
|
1635
|
-
const { getId:
|
|
1722
|
+
function Et(r) {
|
|
1723
|
+
const { getId: t, getChilds: s, rootNodes: o, createSnapshotNode: e } = r, n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), c = Ct(
|
|
1636
1724
|
s,
|
|
1637
1725
|
o,
|
|
1638
1726
|
(u, f) => {
|
|
1639
1727
|
const d = e(u, f);
|
|
1640
1728
|
if (u != null && d != null) {
|
|
1641
|
-
const p =
|
|
1729
|
+
const p = t(u);
|
|
1642
1730
|
n.set(p, d), i.set(d, p);
|
|
1643
1731
|
}
|
|
1644
1732
|
return d != null && f != null && a.set(
|
|
@@ -1657,22 +1745,23 @@ function Et(t) {
|
|
|
1657
1745
|
idToChildIds: a
|
|
1658
1746
|
};
|
|
1659
1747
|
}
|
|
1660
|
-
function me(
|
|
1661
|
-
return
|
|
1748
|
+
function me(r) {
|
|
1749
|
+
return r = r != null ? H(r).replace(/\/$/, "") : null, !r || r === "." ? null : r;
|
|
1662
1750
|
}
|
|
1663
|
-
async function
|
|
1664
|
-
const
|
|
1751
|
+
async function ds(r) {
|
|
1752
|
+
const t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), o = k.resolve(r.rootDir || "."), n = {
|
|
1665
1753
|
path: ".",
|
|
1666
1754
|
name: k.basename(o),
|
|
1667
1755
|
type: "dir",
|
|
1668
1756
|
isMatched: !1,
|
|
1669
1757
|
dateModified: null,
|
|
1670
|
-
size: 0
|
|
1758
|
+
size: 0,
|
|
1759
|
+
countFiles: 0
|
|
1671
1760
|
};
|
|
1672
|
-
|
|
1761
|
+
t.set(null, n);
|
|
1673
1762
|
const i = await $t({
|
|
1674
1763
|
rootDir: o,
|
|
1675
|
-
globs:
|
|
1764
|
+
globs: r.globs
|
|
1676
1765
|
});
|
|
1677
1766
|
return await It({
|
|
1678
1767
|
paths: [o],
|
|
@@ -1686,50 +1775,53 @@ async function us(t) {
|
|
|
1686
1775
|
const u = k.relative(o, a), f = c.isDirectory(), d = c.isFile();
|
|
1687
1776
|
if (!f && !d)
|
|
1688
1777
|
return !0;
|
|
1689
|
-
const p = me(u || "."), h = f ? "dir" : "file", g = f ? null : c.mtimeMs, y = c.size;
|
|
1690
|
-
let
|
|
1691
|
-
if (d && !
|
|
1692
|
-
const [
|
|
1693
|
-
(
|
|
1778
|
+
const p = me(u || "."), h = f ? "dir" : "file", g = f ? l.maxFileDateModified || null : c.mtimeMs, y = f ? l.totalSize : c.size, w = f ? l.countFiles : 1;
|
|
1779
|
+
let I = !0;
|
|
1780
|
+
if (d && !r.matchFiles && (I = !1), f && !r.matchDirs && (I = !1), d && r.dateModified && g != null) {
|
|
1781
|
+
const [T, S] = r.dateModified;
|
|
1782
|
+
if (T != null && g < T || S != null && g > S)
|
|
1783
|
+
return !1;
|
|
1694
1784
|
}
|
|
1695
|
-
if (
|
|
1696
|
-
const [
|
|
1697
|
-
(
|
|
1785
|
+
if (d && r.totalSize && y != null) {
|
|
1786
|
+
const [T, S] = r.totalSize;
|
|
1787
|
+
if (T != null && y < T || S != null && y > S)
|
|
1788
|
+
return !1;
|
|
1698
1789
|
}
|
|
1699
|
-
if (f && !
|
|
1700
|
-
if (!(l.countFiles && l.countFiles > 0)) return !1;
|
|
1701
|
-
} else if (!w)
|
|
1790
|
+
if (f && !I && (!l.countFiles || l.countFiles <= 0))
|
|
1702
1791
|
return !1;
|
|
1703
|
-
|
|
1792
|
+
if (d && !I)
|
|
1793
|
+
return !0;
|
|
1794
|
+
const E = {
|
|
1704
1795
|
path: p ?? ".",
|
|
1705
1796
|
name: k.basename(a),
|
|
1706
1797
|
type: h,
|
|
1707
1798
|
dateModified: g,
|
|
1708
1799
|
size: y,
|
|
1709
|
-
|
|
1800
|
+
countFiles: w,
|
|
1801
|
+
isMatched: I
|
|
1710
1802
|
};
|
|
1711
1803
|
if (p == null)
|
|
1712
|
-
return n.dateModified = g, n.size = y, n.
|
|
1713
|
-
|
|
1714
|
-
const
|
|
1715
|
-
let
|
|
1716
|
-
return
|
|
1804
|
+
return n.dateModified = g, n.size = y, n.countFiles = w, n.isMatched = I, !0;
|
|
1805
|
+
t.set(p, E);
|
|
1806
|
+
const b = me(H(k.dirname(p)));
|
|
1807
|
+
let $ = s.get(b);
|
|
1808
|
+
return $ || ($ = [], s.set(b, $)), $.push(p), !0;
|
|
1717
1809
|
}
|
|
1718
1810
|
}), {
|
|
1719
|
-
idToNode:
|
|
1811
|
+
idToNode: t,
|
|
1720
1812
|
idToChildIds: s
|
|
1721
1813
|
};
|
|
1722
1814
|
}
|
|
1723
|
-
const
|
|
1724
|
-
{ name: "[ ]", match: (
|
|
1725
|
-
{ name: "[\\t]", match: (
|
|
1726
|
-
{ name: "[\\n]", match: (
|
|
1727
|
-
{ name: "[-]", match: (
|
|
1728
|
-
{ name: "[=]", match: (
|
|
1729
|
-
{ name: "[_]", match: (
|
|
1730
|
-
{ name: "[*]", match: (
|
|
1731
|
-
{ name: "[.]", match: (
|
|
1732
|
-
{ name: "[0-9]", match: (
|
|
1815
|
+
const fs = [
|
|
1816
|
+
{ name: "[ ]", match: (r) => r === 32, min: 2, max: 81 },
|
|
1817
|
+
{ name: "[\\t]", match: (r) => r === 9, min: 2, max: 20 },
|
|
1818
|
+
{ name: "[\\n]", match: (r) => r === 10, min: 2, max: 14 },
|
|
1819
|
+
{ name: "[-]", match: (r) => r === 45, min: 2, max: 16 },
|
|
1820
|
+
{ name: "[=]", match: (r) => r === 61, min: 2, max: 16 },
|
|
1821
|
+
{ name: "[_]", match: (r) => r === 95, min: 2, max: 16 },
|
|
1822
|
+
{ name: "[*]", match: (r) => r === 42, min: 2, max: 16 },
|
|
1823
|
+
{ name: "[.]", match: (r) => r === 46, min: 2, max: 16 },
|
|
1824
|
+
{ name: "[0-9]", match: (r) => r >= 48 && r <= 57, min: 2, max: 3 }
|
|
1733
1825
|
// { name: '[a-z]', match: c => c >= 97 && c <= 122, min: 2, max: 2 },
|
|
1734
1826
|
// { name: '[A-Z]', match: c => c >= 65 && c <= 90, min: 2, max: 2 },
|
|
1735
1827
|
// Other ASCII symbols
|
|
@@ -1743,21 +1835,21 @@ const ds = [
|
|
|
1743
1835
|
// max: 2,
|
|
1744
1836
|
// },
|
|
1745
1837
|
];
|
|
1746
|
-
function He(
|
|
1747
|
-
const s =
|
|
1838
|
+
function He(r, t = fs) {
|
|
1839
|
+
const s = r.length;
|
|
1748
1840
|
if (s === 0) return 0;
|
|
1749
|
-
const o =
|
|
1841
|
+
const o = t.length;
|
|
1750
1842
|
if (o === 0)
|
|
1751
1843
|
return s;
|
|
1752
1844
|
let e = 0, n = 0;
|
|
1753
1845
|
for (; n < s; ) {
|
|
1754
|
-
const i =
|
|
1846
|
+
const i = r.charCodeAt(n);
|
|
1755
1847
|
let a = !1;
|
|
1756
1848
|
for (let c = 0; c < o; c++) {
|
|
1757
|
-
const l =
|
|
1849
|
+
const l = t[c];
|
|
1758
1850
|
if (l.match(i)) {
|
|
1759
1851
|
let u = 1;
|
|
1760
|
-
for (; ++n < s && l.match(
|
|
1852
|
+
for (; ++n < s && l.match(r.charCodeAt(n)) && u < l.max; )
|
|
1761
1853
|
u++;
|
|
1762
1854
|
if (u >= l.min) {
|
|
1763
1855
|
e++, a = !0;
|
|
@@ -1769,27 +1861,27 @@ function He(t, r = ds) {
|
|
|
1769
1861
|
}
|
|
1770
1862
|
return e;
|
|
1771
1863
|
}
|
|
1772
|
-
function Nt(
|
|
1773
|
-
let
|
|
1774
|
-
return
|
|
1864
|
+
function Nt(r) {
|
|
1865
|
+
let t = 0;
|
|
1866
|
+
return t += He(r.textOpen) + 1, r.textClose != null && (t += He(r.textClose) + 1), r.indent && (t += 1), t;
|
|
1775
1867
|
}
|
|
1776
1868
|
const Qe = ["B", "KB", "MB", "GB", "TB"], Ye = 1024;
|
|
1777
|
-
function
|
|
1778
|
-
if (
|
|
1779
|
-
let
|
|
1780
|
-
for (;
|
|
1781
|
-
|
|
1782
|
-
return `${s === 0 ?
|
|
1783
|
-
}
|
|
1784
|
-
function
|
|
1785
|
-
const s = Date.now() -
|
|
1869
|
+
function ps(r) {
|
|
1870
|
+
if (r == null) return "-";
|
|
1871
|
+
let t = r ?? 0, s = 0;
|
|
1872
|
+
for (; t >= Ye && s < Qe.length - 1; )
|
|
1873
|
+
t /= Ye, s++;
|
|
1874
|
+
return `${s === 0 ? t.toString() : t.toFixed(2)}${Qe[s]}`;
|
|
1875
|
+
}
|
|
1876
|
+
function hs(r) {
|
|
1877
|
+
const s = Date.now() - r;
|
|
1786
1878
|
if (s < 0) return "0s";
|
|
1787
1879
|
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);
|
|
1788
1880
|
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`;
|
|
1789
1881
|
}
|
|
1790
|
-
function
|
|
1882
|
+
function ms(r) {
|
|
1791
1883
|
return function(s, o) {
|
|
1792
|
-
const e =
|
|
1884
|
+
const e = r.get(s), n = r.get(o);
|
|
1793
1885
|
if (e.type !== n.type)
|
|
1794
1886
|
return e.type === "file" ? -1 : 1;
|
|
1795
1887
|
if (e.type === "file")
|
|
@@ -1800,26 +1892,25 @@ function hs(t) {
|
|
|
1800
1892
|
}
|
|
1801
1893
|
};
|
|
1802
1894
|
}
|
|
1803
|
-
function
|
|
1804
|
-
const
|
|
1895
|
+
function gs(r) {
|
|
1896
|
+
const t = r.fields ?? [];
|
|
1805
1897
|
return function(o, e) {
|
|
1806
1898
|
let n = "", i, a = 0;
|
|
1807
1899
|
const c = e ? e.length : 0;
|
|
1808
|
-
let l = 1, u, f = 0, d = 0, p
|
|
1809
|
-
if (e)
|
|
1900
|
+
let l = 1, u, f = 0, d = 0, p, h, g, y, w, I;
|
|
1901
|
+
if (o ? (y = o.type, w = o.name, I = o.path, p = o.size, h = o.countFiles, g = o.dateModified, i = o.isMatched, i && (a += 1)) : (y = "dir", w = "<root>", I = ".", p = 0, h = 0, g = null, i = !0), e)
|
|
1810
1902
|
for (let b = 0; b < e.length; b++) {
|
|
1811
|
-
const
|
|
1812
|
-
a +=
|
|
1903
|
+
const $ = e[b];
|
|
1904
|
+
a += $.countMatched, l += $.countTotal, f += $.tokens, d += $.tokensTotal, o || (p += $.size, h += $.countFiles, $.dateModified != null && (g == null || $.dateModified > g) && (g = $.dateModified));
|
|
1813
1905
|
}
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
const T = r[b];
|
|
1906
|
+
for (let b = 0, $ = t.length; b < $; b++) {
|
|
1907
|
+
const T = t[b];
|
|
1817
1908
|
switch (b > 0 && (n += " "), T) {
|
|
1818
1909
|
case "dateModified":
|
|
1819
|
-
n += g ?
|
|
1910
|
+
n += g ? hs(g) : "-";
|
|
1820
1911
|
break;
|
|
1821
1912
|
case "size":
|
|
1822
|
-
n +=
|
|
1913
|
+
n += ps(p);
|
|
1823
1914
|
break;
|
|
1824
1915
|
case "type":
|
|
1825
1916
|
n += y;
|
|
@@ -1840,7 +1931,7 @@ function ms(t) {
|
|
|
1840
1931
|
return u = Nt(E), d += u, {
|
|
1841
1932
|
type: y,
|
|
1842
1933
|
name: w,
|
|
1843
|
-
path:
|
|
1934
|
+
path: I,
|
|
1844
1935
|
isMatched: i,
|
|
1845
1936
|
countMatched: a,
|
|
1846
1937
|
countChilds: c,
|
|
@@ -1855,8 +1946,8 @@ function ms(t) {
|
|
|
1855
1946
|
};
|
|
1856
1947
|
};
|
|
1857
1948
|
}
|
|
1858
|
-
async function
|
|
1859
|
-
const
|
|
1949
|
+
async function ws(r) {
|
|
1950
|
+
const t = await ds(r), s = le(t), o = s.getChilds(s.root), e = Et({
|
|
1860
1951
|
getId: (i) => {
|
|
1861
1952
|
const a = s.getId(i);
|
|
1862
1953
|
if (a == null)
|
|
@@ -1866,9 +1957,9 @@ async function gs(t) {
|
|
|
1866
1957
|
return a;
|
|
1867
1958
|
},
|
|
1868
1959
|
getChilds: (i) => s.getChilds(i),
|
|
1869
|
-
createSnapshotNode:
|
|
1960
|
+
createSnapshotNode: gs(r),
|
|
1870
1961
|
rootNodes: o ?? []
|
|
1871
|
-
}), n =
|
|
1962
|
+
}), n = ms(e.idToNode);
|
|
1872
1963
|
return e.idToChildIds.forEach((i) => {
|
|
1873
1964
|
i.sort(n);
|
|
1874
1965
|
}), le(e);
|
|
@@ -1882,10 +1973,10 @@ const ee = m.object({
|
|
|
1882
1973
|
"Unique name for the filesystem snapshot. Recommended format: kebab-case-1, kebab-case-2, ..."
|
|
1883
1974
|
)
|
|
1884
1975
|
});
|
|
1885
|
-
async function ce(
|
|
1976
|
+
async function ce(r, t, s) {
|
|
1886
1977
|
let o;
|
|
1887
1978
|
try {
|
|
1888
|
-
o = ee.parse(
|
|
1979
|
+
o = ee.parse(r);
|
|
1889
1980
|
} catch (u) {
|
|
1890
1981
|
return {
|
|
1891
1982
|
error: F(u)
|
|
@@ -1910,9 +2001,9 @@ async function ce(t, r, s) {
|
|
|
1910
2001
|
};
|
|
1911
2002
|
c = u;
|
|
1912
2003
|
} else if (i) {
|
|
1913
|
-
const u = await
|
|
2004
|
+
const u = await vt(
|
|
1914
2005
|
i,
|
|
1915
|
-
|
|
2006
|
+
t,
|
|
1916
2007
|
s
|
|
1917
2008
|
);
|
|
1918
2009
|
if (u.error != null)
|
|
@@ -1925,7 +2016,7 @@ async function ce(t, r, s) {
|
|
|
1925
2016
|
error: "Either queryName or query must be provided"
|
|
1926
2017
|
};
|
|
1927
2018
|
try {
|
|
1928
|
-
const u = await
|
|
2019
|
+
const u = await ws(c), f = {
|
|
1929
2020
|
name: e,
|
|
1930
2021
|
query: c,
|
|
1931
2022
|
tree: u
|
|
@@ -1940,8 +2031,8 @@ async function ce(t, r, s) {
|
|
|
1940
2031
|
};
|
|
1941
2032
|
}
|
|
1942
2033
|
}
|
|
1943
|
-
function
|
|
1944
|
-
|
|
2034
|
+
function ys(r, t) {
|
|
2035
|
+
r(
|
|
1945
2036
|
"fs-snapshot-create",
|
|
1946
2037
|
{
|
|
1947
2038
|
title: "Create Filesystem Snapshot",
|
|
@@ -1949,7 +2040,7 @@ function ws(t, r) {
|
|
|
1949
2040
|
inputSchema: ee.shape
|
|
1950
2041
|
},
|
|
1951
2042
|
async (s, o) => {
|
|
1952
|
-
const e = await ce(s,
|
|
2043
|
+
const e = await ce(s, t, o);
|
|
1953
2044
|
if (e.error != null)
|
|
1954
2045
|
return `Method: fs-snapshot-create(${JSON.stringify(s)})
|
|
1955
2046
|
❌ Error: ${e.error}`;
|
|
@@ -1960,18 +2051,18 @@ function ws(t, r) {
|
|
|
1960
2051
|
}
|
|
1961
2052
|
);
|
|
1962
2053
|
}
|
|
1963
|
-
class
|
|
2054
|
+
class bs {
|
|
1964
2055
|
_first = null;
|
|
1965
2056
|
_last = null;
|
|
1966
2057
|
_size = 0;
|
|
1967
|
-
enqueue(
|
|
1968
|
-
const s = { item:
|
|
2058
|
+
enqueue(t) {
|
|
2059
|
+
const s = { item: t, next: null };
|
|
1969
2060
|
this._last ? this._last.next = s : this._first = s, this._last = s, this._size += 1;
|
|
1970
2061
|
}
|
|
1971
2062
|
dequeue() {
|
|
1972
2063
|
if (!this._first) return null;
|
|
1973
|
-
const
|
|
1974
|
-
return this._first = this._first.next, this._first || (this._last = null), this._size -= 1,
|
|
2064
|
+
const t = this._first.item;
|
|
2065
|
+
return this._first = this._first.next, this._first || (this._last = null), this._size -= 1, t;
|
|
1975
2066
|
}
|
|
1976
2067
|
peek() {
|
|
1977
2068
|
return this._first ? this._first.item : null;
|
|
@@ -1983,38 +2074,38 @@ class ys {
|
|
|
1983
2074
|
return this._size;
|
|
1984
2075
|
}
|
|
1985
2076
|
}
|
|
1986
|
-
function
|
|
1987
|
-
const
|
|
2077
|
+
function Ss(r) {
|
|
2078
|
+
const t = new bs(), {
|
|
1988
2079
|
tree: s,
|
|
1989
2080
|
limits: { maxCountTotal: o, maxTokensTotal: e, maxCountGroup: n, maxTokensGroup: i },
|
|
1990
2081
|
indexRangeGroupStrategy: a
|
|
1991
|
-
} =
|
|
1992
|
-
c != null && c.length > 0 &&
|
|
2082
|
+
} = r, c = s.getChilds(s.root);
|
|
2083
|
+
c != null && c.length > 0 && t.enqueue({
|
|
1993
2084
|
reportNode: null,
|
|
1994
2085
|
node: s.root
|
|
1995
2086
|
});
|
|
1996
2087
|
let l = null, u = 0, f = 0;
|
|
1997
|
-
for (; !
|
|
1998
|
-
const { reportNode: d, node: p } =
|
|
2088
|
+
for (; !t.isEmpty(); ) {
|
|
2089
|
+
const { reportNode: d, node: p } = t.dequeue(), h = s.getChilds(p);
|
|
1999
2090
|
if (h == null || p.countChilds === 0 || h.length !== p.countChilds)
|
|
2000
2091
|
throw new Error(
|
|
2001
2092
|
"Impossible behavior: nodeChilds is null or length mismatch"
|
|
2002
2093
|
);
|
|
2003
|
-
let g =
|
|
2094
|
+
let g = t.size();
|
|
2004
2095
|
for (let w = 0; w < h.length; w++)
|
|
2005
2096
|
h[w].countChilds > 0 && (g += 1);
|
|
2006
2097
|
const y = g * a.tokens;
|
|
2007
2098
|
if (o != null && u + p.countChilds + g > o || e != null && f + p.tokensChilds + y > e) {
|
|
2008
2099
|
const w = [];
|
|
2009
|
-
let
|
|
2010
|
-
for (let
|
|
2011
|
-
const
|
|
2012
|
-
|
|
2013
|
-
!(o != null && u + 1 > o || e != null && f + a.tokens > e) && (n != null &&
|
|
2100
|
+
let I = null, E = 0;
|
|
2101
|
+
for (let $ = 0, T = h.length; $ < T; $++) {
|
|
2102
|
+
const S = h[$], x = E * a.tokens;
|
|
2103
|
+
I != null && // Если общий лимит превышен, то не создаем новую группу, а продолжаем текущую. В случае достижения лимитов, последняя группа может содержать больше элементов, чем указано в лимитах группы, и это допустимо. Главное - дать в отчете полную картину.
|
|
2104
|
+
!(o != null && u + 1 > o || e != null && f + a.tokens > e) && (n != null && I.countGrouped + 1 + E > n || i != null && I.tokensGrouped + S.tokens + x > i) && (w.push(I), u += 1, f += a.tokens, I = null, E = 0), I = a.add(I, S, $), S.countChilds > 0 && (E += 1);
|
|
2014
2105
|
}
|
|
2015
|
-
|
|
2016
|
-
const b = w.map((
|
|
2017
|
-
text: a.getReportText(
|
|
2106
|
+
I != null && (w.push(I), u += 1, f += a.tokens);
|
|
2107
|
+
const b = w.map(($) => ({
|
|
2108
|
+
text: a.getReportText($)
|
|
2018
2109
|
}));
|
|
2019
2110
|
if (d != null) {
|
|
2020
2111
|
if (d.childs != null)
|
|
@@ -2028,13 +2119,13 @@ function bs(t) {
|
|
|
2028
2119
|
} else {
|
|
2029
2120
|
u += p.countChilds, f += p.tokensChilds;
|
|
2030
2121
|
const w = [];
|
|
2031
|
-
for (let
|
|
2032
|
-
const E = h[
|
|
2122
|
+
for (let I = 0; I < h.length; I++) {
|
|
2123
|
+
const E = h[I], b = {
|
|
2033
2124
|
text: E.text
|
|
2034
2125
|
};
|
|
2035
2126
|
w.push(b);
|
|
2036
|
-
const
|
|
2037
|
-
|
|
2127
|
+
const $ = s.getChilds(E);
|
|
2128
|
+
$ != null && $.length > 0 && t.enqueue({
|
|
2038
2129
|
reportNode: b,
|
|
2039
2130
|
node: E
|
|
2040
2131
|
});
|
|
@@ -2052,22 +2143,22 @@ function bs(t) {
|
|
|
2052
2143
|
}
|
|
2053
2144
|
return l ?? [];
|
|
2054
2145
|
}
|
|
2055
|
-
function kt(
|
|
2146
|
+
function kt(r) {
|
|
2056
2147
|
const {
|
|
2057
|
-
tree:
|
|
2148
|
+
tree: t,
|
|
2058
2149
|
request: { parentNodeId: s, childsIndexRange: o, limits: e },
|
|
2059
2150
|
indexRangeGroupStrategy: n,
|
|
2060
2151
|
...i
|
|
2061
|
-
} =
|
|
2152
|
+
} = r;
|
|
2062
2153
|
let a;
|
|
2063
2154
|
if (s != null) {
|
|
2064
|
-
const d =
|
|
2155
|
+
const d = t.getNode(s);
|
|
2065
2156
|
if (d == null)
|
|
2066
2157
|
throw new Error(`Parent node "${s}" not found`);
|
|
2067
2158
|
a = d;
|
|
2068
2159
|
} else
|
|
2069
|
-
a =
|
|
2070
|
-
let c, l =
|
|
2160
|
+
a = t.root;
|
|
2161
|
+
let c, l = t.getChilds(a) ?? [];
|
|
2071
2162
|
if (o != null) {
|
|
2072
2163
|
let [d, p] = o;
|
|
2073
2164
|
if (d < 0 && (d = 0), p < 0 && (p = 0), p >= l.length && (p = l.length - 1), p < d)
|
|
@@ -2090,19 +2181,19 @@ function kt(t) {
|
|
|
2090
2181
|
countChilds: 1,
|
|
2091
2182
|
tokensChilds: c.tokens
|
|
2092
2183
|
}, f = {
|
|
2093
|
-
...
|
|
2184
|
+
...t,
|
|
2094
2185
|
root: u,
|
|
2095
|
-
getChilds: (d) => d === u ? [c] : d === c ? l :
|
|
2186
|
+
getChilds: (d) => d === u ? [c] : d === c ? l : t.getChilds(d)
|
|
2096
2187
|
};
|
|
2097
|
-
return
|
|
2188
|
+
return Ss({
|
|
2098
2189
|
tree: f,
|
|
2099
2190
|
limits: e,
|
|
2100
2191
|
indexRangeGroupStrategy: n,
|
|
2101
2192
|
...i
|
|
2102
2193
|
});
|
|
2103
2194
|
}
|
|
2104
|
-
function Ot(
|
|
2105
|
-
if (
|
|
2195
|
+
function Ot(r, t) {
|
|
2196
|
+
if (r == null || r.length === 0)
|
|
2106
2197
|
return "No results found";
|
|
2107
2198
|
let s = "";
|
|
2108
2199
|
function o(e, n) {
|
|
@@ -2116,22 +2207,22 @@ function Ot(t, r) {
|
|
|
2116
2207
|
`);
|
|
2117
2208
|
}
|
|
2118
2209
|
}
|
|
2119
|
-
return o(
|
|
2210
|
+
return o(r, ""), s;
|
|
2120
2211
|
}
|
|
2121
|
-
class
|
|
2212
|
+
class xs {
|
|
2122
2213
|
tokens = 16;
|
|
2123
2214
|
// +1 indent, +1 for line break
|
|
2124
|
-
getReportText = (
|
|
2215
|
+
getReportText = (t) => ({
|
|
2125
2216
|
indent: !0,
|
|
2126
|
-
textOpen: `[${
|
|
2217
|
+
textOpen: `[${t.indexRange[0]}-${t.indexRange[1]}] see more ${t.countMatched} matched ${t.tokensGrouped} tokens`,
|
|
2127
2218
|
textClose: null
|
|
2128
2219
|
});
|
|
2129
|
-
add = (
|
|
2220
|
+
add = (t, s, o) => t == null ? {
|
|
2130
2221
|
indexRange: [o, o],
|
|
2131
2222
|
countGrouped: 1,
|
|
2132
2223
|
countMatched: s.countMatched,
|
|
2133
2224
|
tokensGrouped: s.tokens
|
|
2134
|
-
} : (
|
|
2225
|
+
} : (t.indexRange[1] = o, t.countGrouped += 1, t.countMatched += s.countMatched, t.tokensGrouped += s.tokens, t);
|
|
2135
2226
|
}
|
|
2136
2227
|
const Rt = m.object({
|
|
2137
2228
|
snapshotName: m.string().optional().describe("Name of previously created filesystem snapshot, to use"),
|
|
@@ -2155,10 +2246,10 @@ const Rt = m.object({
|
|
|
2155
2246
|
// maxCountGroup: z.number().default(10).describe('Maximum items per group'),
|
|
2156
2247
|
// maxTokensGroup: z.number().default(1000).describe('Maximum tokens per group'),
|
|
2157
2248
|
});
|
|
2158
|
-
async function
|
|
2249
|
+
async function Is(r, t, s) {
|
|
2159
2250
|
let o;
|
|
2160
2251
|
try {
|
|
2161
|
-
o = Rt.parse(
|
|
2252
|
+
o = Rt.parse(r);
|
|
2162
2253
|
} catch (g) {
|
|
2163
2254
|
return {
|
|
2164
2255
|
error: F(g)
|
|
@@ -2190,7 +2281,7 @@ async function xs(t, r, s) {
|
|
|
2190
2281
|
} else if (n) {
|
|
2191
2282
|
const g = await ce(
|
|
2192
2283
|
n,
|
|
2193
|
-
|
|
2284
|
+
t,
|
|
2194
2285
|
s
|
|
2195
2286
|
);
|
|
2196
2287
|
if (g.error != null)
|
|
@@ -2215,7 +2306,7 @@ async function xs(t, r, s) {
|
|
|
2215
2306
|
maxTokensGroup: u
|
|
2216
2307
|
}
|
|
2217
2308
|
},
|
|
2218
|
-
indexRangeGroupStrategy: new
|
|
2309
|
+
indexRangeGroupStrategy: new xs()
|
|
2219
2310
|
}), w = Ot(y);
|
|
2220
2311
|
return {
|
|
2221
2312
|
fsSnapshot: d,
|
|
@@ -2231,8 +2322,8 @@ async function xs(t, r, s) {
|
|
|
2231
2322
|
};
|
|
2232
2323
|
}
|
|
2233
2324
|
}
|
|
2234
|
-
function
|
|
2235
|
-
|
|
2325
|
+
function $s(r, t) {
|
|
2326
|
+
r(
|
|
2236
2327
|
"fs-snapshot-browse",
|
|
2237
2328
|
{
|
|
2238
2329
|
title: "Browse Filesystem Snapshot",
|
|
@@ -2240,7 +2331,7 @@ function Is(t, r) {
|
|
|
2240
2331
|
inputSchema: Rt.shape
|
|
2241
2332
|
},
|
|
2242
2333
|
async (s, o) => {
|
|
2243
|
-
const e = await
|
|
2334
|
+
const e = await Is(s, t, o);
|
|
2244
2335
|
if (e.error != null)
|
|
2245
2336
|
return `Method: fs-snapshot-browse(${JSON.stringify(s)})
|
|
2246
2337
|
❌ Error: ${e.error}`;
|
|
@@ -2262,26 +2353,26 @@ ${e.report}`, n;
|
|
|
2262
2353
|
}
|
|
2263
2354
|
);
|
|
2264
2355
|
}
|
|
2265
|
-
function Dt(
|
|
2266
|
-
const
|
|
2356
|
+
function Dt(r) {
|
|
2357
|
+
const t = [], s = r.tree, o = r.query.rootDir ?? ".";
|
|
2267
2358
|
function e(n) {
|
|
2268
|
-
n.type === "file" && n.isMatched &&
|
|
2359
|
+
n.type === "file" && n.isMatched && t.push(o + "/" + n.path);
|
|
2269
2360
|
const i = s.getChilds(n);
|
|
2270
2361
|
if (i != null)
|
|
2271
2362
|
for (let a = 0; a < i.length; a++)
|
|
2272
2363
|
e(i[a]);
|
|
2273
2364
|
}
|
|
2274
|
-
return e(s.root),
|
|
2365
|
+
return e(s.root), t;
|
|
2275
2366
|
}
|
|
2276
2367
|
const Ve = /* @__PURE__ */ new Map();
|
|
2277
|
-
function
|
|
2278
|
-
const
|
|
2279
|
-
let s = Ve.get(
|
|
2280
|
-
return s == null && (s = new nr(), Ve.set(
|
|
2281
|
-
}
|
|
2282
|
-
async function
|
|
2283
|
-
const { filePath:
|
|
2284
|
-
return
|
|
2368
|
+
function Ms(r) {
|
|
2369
|
+
const t = H(r);
|
|
2370
|
+
let s = Ve.get(t);
|
|
2371
|
+
return s == null && (s = new nr(), Ve.set(t, s)), s;
|
|
2372
|
+
}
|
|
2373
|
+
async function Ts(r) {
|
|
2374
|
+
const { filePath: t, func: s } = r;
|
|
2375
|
+
return Ms(t).lock(
|
|
2285
2376
|
() => V({
|
|
2286
2377
|
pool: Se,
|
|
2287
2378
|
count: 1,
|
|
@@ -2289,54 +2380,54 @@ async function Ms(t) {
|
|
|
2289
2380
|
})
|
|
2290
2381
|
);
|
|
2291
2382
|
}
|
|
2292
|
-
const Ze = 10, re = 48, Xe = 57, de = 36,
|
|
2293
|
-
function
|
|
2294
|
-
const { content:
|
|
2383
|
+
const Ze = 10, re = 48, Xe = 57, de = 36, vs = 38, Cs = 39, Es = 60, Ns = 62, ks = 96, se = 0, et = 1, tt = 2, rt = 3, st = 4, Os = 5;
|
|
2384
|
+
function Rs(r) {
|
|
2385
|
+
const { content: t, pattern: s, replacement: o } = r, e = t.length, n = [0];
|
|
2295
2386
|
for (let b = 0; b < e; b++)
|
|
2296
|
-
|
|
2387
|
+
t.charCodeAt(b) === Ze && b + 1 < e && n.push(b + 1);
|
|
2297
2388
|
const i = n.length, a = [], c = [];
|
|
2298
2389
|
let l = null, u = null, f = null, d = 0;
|
|
2299
2390
|
if (o != null) {
|
|
2300
2391
|
const b = o.length;
|
|
2301
|
-
let
|
|
2392
|
+
let $ = !1;
|
|
2302
2393
|
for (let T = 0; T < b; T++)
|
|
2303
2394
|
if (o.charCodeAt(T) === de) {
|
|
2304
|
-
|
|
2395
|
+
$ = !0;
|
|
2305
2396
|
break;
|
|
2306
2397
|
}
|
|
2307
|
-
if (
|
|
2398
|
+
if ($) {
|
|
2308
2399
|
u = [], f = [];
|
|
2309
|
-
let T = 0,
|
|
2310
|
-
for (;
|
|
2311
|
-
if (o.charCodeAt(
|
|
2312
|
-
|
|
2400
|
+
let T = 0, S = 0;
|
|
2401
|
+
for (; S < b; ) {
|
|
2402
|
+
if (o.charCodeAt(S) !== de || S + 1 >= b) {
|
|
2403
|
+
S++;
|
|
2313
2404
|
continue;
|
|
2314
2405
|
}
|
|
2315
|
-
const
|
|
2316
|
-
let
|
|
2317
|
-
if (
|
|
2318
|
-
|
|
2319
|
-
else if (
|
|
2320
|
-
|
|
2321
|
-
else if (
|
|
2322
|
-
|
|
2323
|
-
else if (
|
|
2324
|
-
|
|
2325
|
-
else if (
|
|
2326
|
-
let
|
|
2327
|
-
for (;
|
|
2328
|
-
const
|
|
2329
|
-
if (
|
|
2330
|
-
|
|
2406
|
+
const x = o.charCodeAt(S + 1);
|
|
2407
|
+
let C = -1, P = 0, O = 2;
|
|
2408
|
+
if (x === de)
|
|
2409
|
+
C = se, P = "$";
|
|
2410
|
+
else if (x === vs)
|
|
2411
|
+
C = et;
|
|
2412
|
+
else if (x === ks)
|
|
2413
|
+
C = tt;
|
|
2414
|
+
else if (x === Cs)
|
|
2415
|
+
C = rt;
|
|
2416
|
+
else if (x >= re && x <= Xe) {
|
|
2417
|
+
let M = S + 2;
|
|
2418
|
+
for (; M < b; ) {
|
|
2419
|
+
const v = o.charCodeAt(M);
|
|
2420
|
+
if (v < re || v > Xe) break;
|
|
2421
|
+
M++;
|
|
2331
2422
|
}
|
|
2332
|
-
|
|
2333
|
-
} else if (
|
|
2334
|
-
let
|
|
2335
|
-
for (;
|
|
2336
|
-
|
|
2337
|
-
|
|
2423
|
+
C = st, P = o.substring(S + 1, M), O = M - S;
|
|
2424
|
+
} else if (x === Es) {
|
|
2425
|
+
let M = S + 2;
|
|
2426
|
+
for (; M < b && o.charCodeAt(M) !== Ns; )
|
|
2427
|
+
M++;
|
|
2428
|
+
M < b && M > S + 2 && (C = Os, P = o.substring(S + 2, M), O = M + 1 - S);
|
|
2338
2429
|
}
|
|
2339
|
-
|
|
2430
|
+
C >= 0 ? (S > T && (u.push(se), f.push(o.substring(T, S))), u.push(C), f.push(P), S += O, T = S) : S++;
|
|
2340
2431
|
}
|
|
2341
2432
|
T < b && (u.push(se), f.push(o.substring(T))), d = u.length;
|
|
2342
2433
|
} else
|
|
@@ -2345,132 +2436,132 @@ function Os(t) {
|
|
|
2345
2436
|
let p = "", h = 0, g = 0;
|
|
2346
2437
|
s.lastIndex = 0;
|
|
2347
2438
|
let y;
|
|
2348
|
-
for (; (y = s.exec(
|
|
2349
|
-
const b = y.index,
|
|
2350
|
-
let
|
|
2439
|
+
for (; (y = s.exec(t)) !== null; ) {
|
|
2440
|
+
const b = y.index, $ = y[0], T = $.length, S = b + T;
|
|
2441
|
+
let x, C, P, O;
|
|
2351
2442
|
if (i === 1)
|
|
2352
|
-
|
|
2443
|
+
x = 0, C = 1, P = 0, O = e;
|
|
2353
2444
|
else {
|
|
2354
|
-
let
|
|
2355
|
-
for (;
|
|
2356
|
-
const N =
|
|
2357
|
-
n[N] <= b ?
|
|
2445
|
+
let M = 0, v = i - 1;
|
|
2446
|
+
for (; M < v; ) {
|
|
2447
|
+
const N = M + v + 1 >> 1;
|
|
2448
|
+
n[N] <= b ? M = N : v = N - 1;
|
|
2358
2449
|
}
|
|
2359
|
-
if (
|
|
2360
|
-
const N =
|
|
2361
|
-
for (
|
|
2362
|
-
const R =
|
|
2363
|
-
n[R] <= N ?
|
|
2450
|
+
if (x = M, T > 0) {
|
|
2451
|
+
const N = S - 1;
|
|
2452
|
+
for (v = i - 1; M < v; ) {
|
|
2453
|
+
const R = M + v + 1 >> 1;
|
|
2454
|
+
n[R] <= N ? M = R : v = R - 1;
|
|
2364
2455
|
}
|
|
2365
|
-
|
|
2456
|
+
C = M + 1;
|
|
2366
2457
|
} else
|
|
2367
|
-
|
|
2368
|
-
P = n[
|
|
2458
|
+
C = x + 1;
|
|
2459
|
+
P = n[x], O = C < i ? n[C] : e;
|
|
2369
2460
|
}
|
|
2370
2461
|
if (a.push({
|
|
2371
|
-
offset: [b,
|
|
2372
|
-
lines: [
|
|
2462
|
+
offset: [b, S],
|
|
2463
|
+
lines: [x, C],
|
|
2373
2464
|
linesOffset: [P, O]
|
|
2374
2465
|
}), o != null) {
|
|
2375
|
-
p +=
|
|
2376
|
-
let
|
|
2466
|
+
p += t.substring(h, b);
|
|
2467
|
+
let M;
|
|
2377
2468
|
if (l != null)
|
|
2378
|
-
|
|
2469
|
+
M = l;
|
|
2379
2470
|
else {
|
|
2380
|
-
|
|
2471
|
+
M = "";
|
|
2381
2472
|
const N = y.groups, R = y.length - 1;
|
|
2382
2473
|
for (let K = 0; K < d; K++) {
|
|
2383
|
-
const
|
|
2384
|
-
switch (
|
|
2474
|
+
const j = u[K], L = f[K];
|
|
2475
|
+
switch (j) {
|
|
2385
2476
|
case se:
|
|
2386
|
-
|
|
2477
|
+
M += L;
|
|
2387
2478
|
break;
|
|
2388
2479
|
case et:
|
|
2389
|
-
|
|
2480
|
+
M += $;
|
|
2390
2481
|
break;
|
|
2391
2482
|
case tt:
|
|
2392
|
-
|
|
2483
|
+
M += t.substring(0, b);
|
|
2393
2484
|
break;
|
|
2394
2485
|
case rt:
|
|
2395
|
-
|
|
2486
|
+
M += t.substring(S);
|
|
2396
2487
|
break;
|
|
2397
2488
|
case st: {
|
|
2398
2489
|
const B = L, z = B.length, A = B.charCodeAt(0) - re;
|
|
2399
2490
|
if (z >= 2) {
|
|
2400
|
-
const
|
|
2491
|
+
const q = B.charCodeAt(1) - re, D = A * 10 + q;
|
|
2401
2492
|
if (D >= 1 && D <= R) {
|
|
2402
|
-
|
|
2493
|
+
M += y[D] ?? "", z > 2 && (M += B.substring(2));
|
|
2403
2494
|
break;
|
|
2404
2495
|
}
|
|
2405
2496
|
}
|
|
2406
|
-
A >= 1 && A <= R ? (
|
|
2497
|
+
A >= 1 && A <= R ? (M += y[A] ?? "", z > 1 && (M += B.substring(1))) : M += "$" + B;
|
|
2407
2498
|
break;
|
|
2408
2499
|
}
|
|
2409
2500
|
default:
|
|
2410
|
-
N != null ?
|
|
2501
|
+
N != null ? M += N[L] ?? "" : M += "$<" + L + ">";
|
|
2411
2502
|
}
|
|
2412
2503
|
}
|
|
2413
2504
|
}
|
|
2414
|
-
p +=
|
|
2415
|
-
const
|
|
2505
|
+
p += M;
|
|
2506
|
+
const v = b + g;
|
|
2416
2507
|
c.push({
|
|
2417
|
-
offset: [
|
|
2508
|
+
offset: [v, v + M.length],
|
|
2418
2509
|
lines: [0, 0],
|
|
2419
2510
|
linesOffset: [0, 0]
|
|
2420
|
-
}), g +=
|
|
2511
|
+
}), g += M.length - T, h = S;
|
|
2421
2512
|
}
|
|
2422
2513
|
if (T === 0 && s.lastIndex++, !s.global)
|
|
2423
2514
|
break;
|
|
2424
2515
|
}
|
|
2425
2516
|
if (s.lastIndex = 0, o == null)
|
|
2426
|
-
return { search: { content:
|
|
2427
|
-
p +=
|
|
2428
|
-
const w = p.length,
|
|
2517
|
+
return { search: { content: t, matches: a }, replace: null };
|
|
2518
|
+
p += t.substring(h);
|
|
2519
|
+
const w = p.length, I = [0];
|
|
2429
2520
|
for (let b = 0; b < w; b++)
|
|
2430
|
-
p.charCodeAt(b) === Ze && b + 1 < w &&
|
|
2431
|
-
const E =
|
|
2432
|
-
for (let b = 0,
|
|
2433
|
-
const T = c[b],
|
|
2434
|
-
let
|
|
2521
|
+
p.charCodeAt(b) === Ze && b + 1 < w && I.push(b + 1);
|
|
2522
|
+
const E = I.length;
|
|
2523
|
+
for (let b = 0, $ = c.length; b < $; b++) {
|
|
2524
|
+
const T = c[b], S = T.offset[0], x = T.offset[1];
|
|
2525
|
+
let C, P, O, M;
|
|
2435
2526
|
if (E === 1)
|
|
2436
|
-
|
|
2527
|
+
C = 0, P = 1, O = 0, M = w;
|
|
2437
2528
|
else {
|
|
2438
|
-
let
|
|
2439
|
-
for (;
|
|
2440
|
-
const R =
|
|
2441
|
-
|
|
2529
|
+
let v = 0, N = E - 1;
|
|
2530
|
+
for (; v < N; ) {
|
|
2531
|
+
const R = v + N + 1 >> 1;
|
|
2532
|
+
I[R] <= S ? v = R : N = R - 1;
|
|
2442
2533
|
}
|
|
2443
|
-
if (
|
|
2444
|
-
const R =
|
|
2445
|
-
for (N = E - 1;
|
|
2446
|
-
const K =
|
|
2447
|
-
|
|
2534
|
+
if (C = v, x > S) {
|
|
2535
|
+
const R = x - 1;
|
|
2536
|
+
for (N = E - 1; v < N; ) {
|
|
2537
|
+
const K = v + N + 1 >> 1;
|
|
2538
|
+
I[K] <= R ? v = K : N = K - 1;
|
|
2448
2539
|
}
|
|
2449
|
-
P = C + 1;
|
|
2450
|
-
} else
|
|
2451
2540
|
P = v + 1;
|
|
2452
|
-
|
|
2541
|
+
} else
|
|
2542
|
+
P = C + 1;
|
|
2543
|
+
O = I[C], M = P < E ? I[P] : w;
|
|
2453
2544
|
}
|
|
2454
|
-
T.lines[0] =
|
|
2545
|
+
T.lines[0] = C, T.lines[1] = P, T.linesOffset[0] = O, T.linesOffset[1] = M;
|
|
2455
2546
|
}
|
|
2456
2547
|
return {
|
|
2457
|
-
search: { content:
|
|
2548
|
+
search: { content: t, matches: a },
|
|
2458
2549
|
replace: { content: p, matches: c }
|
|
2459
2550
|
};
|
|
2460
2551
|
}
|
|
2461
|
-
function Ft(
|
|
2462
|
-
if (
|
|
2552
|
+
function Ft(r) {
|
|
2553
|
+
if (r.length === 0)
|
|
2463
2554
|
return [];
|
|
2464
|
-
const
|
|
2555
|
+
const t = [...r].sort((i, a) => {
|
|
2465
2556
|
const c = i.lines[0], l = a.lines[0];
|
|
2466
2557
|
if (c > l) return 1;
|
|
2467
2558
|
if (c < l) return -1;
|
|
2468
2559
|
const u = i.lines[1], f = a.lines[1];
|
|
2469
2560
|
return u > f ? 1 : u < f ? -1 : 0;
|
|
2470
2561
|
}), s = [];
|
|
2471
|
-
let o = [...
|
|
2472
|
-
for (let i = 1; i <
|
|
2473
|
-
const a =
|
|
2562
|
+
let o = [...t[0].offset], e = [...t[0].lines], n = [...t[0].linesOffset];
|
|
2563
|
+
for (let i = 1; i < t.length; i++) {
|
|
2564
|
+
const a = t[i];
|
|
2474
2565
|
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({
|
|
2475
2566
|
offset: o,
|
|
2476
2567
|
lines: e,
|
|
@@ -2483,51 +2574,51 @@ function Ft(t) {
|
|
|
2483
2574
|
linesOffset: n
|
|
2484
2575
|
}), s;
|
|
2485
2576
|
}
|
|
2486
|
-
function oe(
|
|
2577
|
+
function oe(r, t, s, o) {
|
|
2487
2578
|
let e = 0, n = 0;
|
|
2488
2579
|
for (let u = 0; u < s; u++)
|
|
2489
|
-
|
|
2580
|
+
r.charCodeAt(u) === 10 && (n = u + 1, e++);
|
|
2490
2581
|
const i = e, a = n;
|
|
2491
2582
|
let c = s;
|
|
2492
2583
|
for (; c < o; c++)
|
|
2493
|
-
|
|
2584
|
+
r.charCodeAt(c) === 10 && e++;
|
|
2494
2585
|
const l = e + 1;
|
|
2495
|
-
for (; c <
|
|
2496
|
-
if (
|
|
2586
|
+
for (; c < t; c++)
|
|
2587
|
+
if (r.charCodeAt(c) === 10)
|
|
2497
2588
|
return { startLine: i, endLine: l, startLineOfs: a, endLineOfs: c + 1 };
|
|
2498
|
-
return { startLine: i, endLine: l, startLineOfs: a, endLineOfs:
|
|
2589
|
+
return { startLine: i, endLine: l, startLineOfs: a, endLineOfs: t };
|
|
2499
2590
|
}
|
|
2500
|
-
function
|
|
2501
|
-
if (
|
|
2502
|
-
const
|
|
2591
|
+
function Ds(r, t) {
|
|
2592
|
+
if (r.replace == null && t.replace == null) {
|
|
2593
|
+
const _ = [...r.search.matches, ...t.search.matches];
|
|
2503
2594
|
return {
|
|
2504
|
-
search: { content:
|
|
2595
|
+
search: { content: r.search.content, matches: Ft(_) },
|
|
2505
2596
|
replace: null
|
|
2506
2597
|
};
|
|
2507
2598
|
}
|
|
2508
|
-
const s =
|
|
2509
|
-
let y = 0, w = 0,
|
|
2599
|
+
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 = [];
|
|
2600
|
+
let y = 0, w = 0, I = 0, E = 0, b = 0, $ = 0, T = 0, S = 0, x = 0, C = 0, P = 0, O = 0, M = 0, v = 0, N = 0, R = 0, K = 0, j = 0, L = 0, B = 0, z = 0, A = 0, q = 0, D = 0;
|
|
2510
2601
|
for (; y < d || w < p; )
|
|
2511
|
-
if (y < d && (b = l[y].offset[0],
|
|
2512
|
-
K = b < T ? b : T,
|
|
2602
|
+
if (y < d && (b = l[y].offset[0], $ = l[y].offset[1]), w < p && (T = u[w].offset[0], S = u[w].offset[1]), y < d && w < p && b < S && T < $) {
|
|
2603
|
+
K = b < T ? b : T, x = $ > S ? $ : S, P = y, O = w, y++, w++;
|
|
2513
2604
|
do {
|
|
2514
|
-
for (
|
|
2515
|
-
|
|
2516
|
-
for (; w < p && u[w].offset[0] <
|
|
2517
|
-
|
|
2518
|
-
} while (
|
|
2519
|
-
|
|
2605
|
+
for (C = x; y < d && l[y].offset[0] < x; )
|
|
2606
|
+
$ = l[y].offset[1], $ > x && (x = $), y++;
|
|
2607
|
+
for (; w < p && u[w].offset[0] < x; )
|
|
2608
|
+
S = u[w].offset[1], S > x && (x = S), w++;
|
|
2609
|
+
} while (x !== C);
|
|
2610
|
+
M = 1 / 0, v = -1 / 0, j = K, L = I;
|
|
2520
2611
|
for (let G = P; G < y; G++)
|
|
2521
|
-
B = c[G].offset[0], z = c[G].offset[1], A = l[G].offset[0],
|
|
2522
|
-
|
|
2612
|
+
B = c[G].offset[0], z = c[G].offset[1], A = l[G].offset[0], q = l[G].offset[1], j < A && (D = j + L, D < M && (M = D), D = A + L, D > v && (v = D)), B < M && (M = B), z > v && (v = z), L += z - B - q + A, j = q;
|
|
2613
|
+
j < x && (D = j + L, D < M && (M = D), D = x + L, D > v && (v = D)), I = L, N = 1 / 0, R = -1 / 0, j = K, L = E;
|
|
2523
2614
|
for (let G = O; G < w; G++)
|
|
2524
|
-
B = u[G].offset[0], z = u[G].offset[1], A = f[G].offset[0],
|
|
2525
|
-
|
|
2526
|
-
const
|
|
2615
|
+
B = u[G].offset[0], z = u[G].offset[1], A = f[G].offset[0], q = f[G].offset[1], j < B && (D = j + L, D < N && (N = D), D = B + L, D > R && (R = D)), A < N && (N = A), q > R && (R = q), L += q - A - z + B, j = z;
|
|
2616
|
+
j < x && (D = j + L, D < N && (N = D), D = x + L, D > R && (R = D)), E = L;
|
|
2617
|
+
const _ = oe(e, i, M, v);
|
|
2527
2618
|
h.push({
|
|
2528
|
-
offset: [
|
|
2529
|
-
lines: [
|
|
2530
|
-
linesOffset: [
|
|
2619
|
+
offset: [M, v],
|
|
2620
|
+
lines: [_.startLine, _.endLine],
|
|
2621
|
+
linesOffset: [_.startLineOfs, _.endLineOfs]
|
|
2531
2622
|
});
|
|
2532
2623
|
const te = oe(n, a, N, R);
|
|
2533
2624
|
g.push({
|
|
@@ -2536,38 +2627,38 @@ function Rs(t, r) {
|
|
|
2536
2627
|
linesOffset: [te.startLineOfs, te.endLineOfs]
|
|
2537
2628
|
});
|
|
2538
2629
|
} else if (w >= p || y < d && b <= T) {
|
|
2539
|
-
B = c[y].offset[0], z = c[y].offset[1], A = l[y].offset[0],
|
|
2540
|
-
const
|
|
2630
|
+
B = c[y].offset[0], z = c[y].offset[1], A = l[y].offset[0], q = l[y].offset[1], N = A + E, R = q + E;
|
|
2631
|
+
const _ = oe(n, a, N, R);
|
|
2541
2632
|
h.push(c[y]), g.push({
|
|
2542
2633
|
offset: [N, R],
|
|
2543
|
-
lines: [
|
|
2544
|
-
linesOffset: [
|
|
2545
|
-
}),
|
|
2634
|
+
lines: [_.startLine, _.endLine],
|
|
2635
|
+
linesOffset: [_.startLineOfs, _.endLineOfs]
|
|
2636
|
+
}), I += z - B - q + A, y++;
|
|
2546
2637
|
} else {
|
|
2547
|
-
B = u[w].offset[0], z = u[w].offset[1], A = f[w].offset[0],
|
|
2548
|
-
const
|
|
2638
|
+
B = u[w].offset[0], z = u[w].offset[1], A = f[w].offset[0], q = f[w].offset[1], M = B + I, v = z + I;
|
|
2639
|
+
const _ = oe(e, i, M, v);
|
|
2549
2640
|
h.push({
|
|
2550
|
-
offset: [
|
|
2551
|
-
lines: [
|
|
2552
|
-
linesOffset: [
|
|
2553
|
-
}), g.push(f[w]), E +=
|
|
2641
|
+
offset: [M, v],
|
|
2642
|
+
lines: [_.startLine, _.endLine],
|
|
2643
|
+
linesOffset: [_.startLineOfs, _.endLineOfs]
|
|
2644
|
+
}), g.push(f[w]), E += q - A - z + B, w++;
|
|
2554
2645
|
}
|
|
2555
2646
|
return {
|
|
2556
2647
|
search: { content: e, matches: h },
|
|
2557
2648
|
replace: { content: n, matches: g }
|
|
2558
2649
|
};
|
|
2559
2650
|
}
|
|
2560
|
-
async function
|
|
2561
|
-
const { filePath:
|
|
2562
|
-
return s.length === 0 ? { filePath:
|
|
2563
|
-
filePath:
|
|
2651
|
+
async function Fs(r) {
|
|
2652
|
+
const { filePath: t, operations: s, dryRun: o } = r;
|
|
2653
|
+
return s.length === 0 ? { filePath: t, result: null } : Ts({
|
|
2654
|
+
filePath: t,
|
|
2564
2655
|
func: async () => {
|
|
2565
2656
|
let e;
|
|
2566
2657
|
try {
|
|
2567
|
-
e = await
|
|
2658
|
+
e = await U.promises.readFile(t, "utf-8");
|
|
2568
2659
|
} catch (a) {
|
|
2569
2660
|
return {
|
|
2570
|
-
filePath:
|
|
2661
|
+
filePath: t,
|
|
2571
2662
|
result: null,
|
|
2572
2663
|
error: `Failed to read file: ${a instanceof Error ? a.message : a + ""}`
|
|
2573
2664
|
};
|
|
@@ -2580,41 +2671,41 @@ async function Ds(t) {
|
|
|
2580
2671
|
l = new RegExp(c.pattern, c.flags ?? "");
|
|
2581
2672
|
} catch (d) {
|
|
2582
2673
|
return {
|
|
2583
|
-
filePath:
|
|
2674
|
+
filePath: t,
|
|
2584
2675
|
result: null,
|
|
2585
2676
|
error: `Invalid RegExp pattern "${c.pattern}": ${d instanceof Error ? d.message : d + ""}`
|
|
2586
2677
|
};
|
|
2587
2678
|
}
|
|
2588
|
-
const u = n?.replace?.content ?? e, f =
|
|
2679
|
+
const u = n?.replace?.content ?? e, f = Rs({
|
|
2589
2680
|
content: u,
|
|
2590
2681
|
pattern: l,
|
|
2591
2682
|
replacement: c.replacement
|
|
2592
2683
|
});
|
|
2593
|
-
c.replacement != null && (i = !0), n == null ? n = f : n =
|
|
2684
|
+
c.replacement != null && (i = !0), n == null ? n = f : n = Ds(n, f);
|
|
2594
2685
|
}
|
|
2595
2686
|
if (i && n?.replace != null && !o) {
|
|
2596
2687
|
const a = n.replace.content;
|
|
2597
2688
|
if (a !== e)
|
|
2598
2689
|
try {
|
|
2599
|
-
await
|
|
2690
|
+
await U.promises.writeFile(t, a, "utf-8");
|
|
2600
2691
|
} catch (c) {
|
|
2601
2692
|
return {
|
|
2602
|
-
filePath:
|
|
2693
|
+
filePath: t,
|
|
2603
2694
|
result: n,
|
|
2604
2695
|
error: `Failed to write file: ${c instanceof Error ? c.message : c + ""}`
|
|
2605
2696
|
};
|
|
2606
2697
|
}
|
|
2607
2698
|
}
|
|
2608
|
-
return { filePath:
|
|
2699
|
+
return { filePath: t, result: n };
|
|
2609
2700
|
}
|
|
2610
2701
|
});
|
|
2611
2702
|
}
|
|
2612
|
-
async function Ie(
|
|
2613
|
-
const { filePaths:
|
|
2703
|
+
async function Ie(r) {
|
|
2704
|
+
const { filePaths: t, operations: s, dryRun: o, dateModifiedMax: e } = r;
|
|
2614
2705
|
return { results: await Promise.all(
|
|
2615
|
-
|
|
2706
|
+
t.map(async (i) => {
|
|
2616
2707
|
if (e != null) {
|
|
2617
|
-
const a = await
|
|
2708
|
+
const a = await U.promises.stat(i).catch(() => null);
|
|
2618
2709
|
if (a == null)
|
|
2619
2710
|
return {
|
|
2620
2711
|
filePath: i,
|
|
@@ -2628,34 +2719,34 @@ async function Ie(t) {
|
|
|
2628
2719
|
error: "Not replaced, try again"
|
|
2629
2720
|
};
|
|
2630
2721
|
}
|
|
2631
|
-
return
|
|
2722
|
+
return Fs({ filePath: i, operations: s, dryRun: o });
|
|
2632
2723
|
})
|
|
2633
2724
|
) };
|
|
2634
2725
|
}
|
|
2635
|
-
const
|
|
2636
|
-
function
|
|
2637
|
-
const { content:
|
|
2726
|
+
const Ps = 6;
|
|
2727
|
+
function Bs(r) {
|
|
2728
|
+
const { content: t, startLine: s } = r, o = r.padWidth ?? Ps;
|
|
2638
2729
|
let e = "", n = 0, i = 0;
|
|
2639
|
-
for (; n <
|
|
2640
|
-
const a =
|
|
2641
|
-
`, n), c = a === -1 ?
|
|
2642
|
-
e += String(s + i + 1).padStart(o) + "→" +
|
|
2730
|
+
for (; n < t.length; ) {
|
|
2731
|
+
const a = t.indexOf(`
|
|
2732
|
+
`, n), c = a === -1 ? t.length : a + 1;
|
|
2733
|
+
e += String(s + i + 1).padStart(o) + "→" + t.substring(n, c), n = c, i++;
|
|
2643
2734
|
}
|
|
2644
2735
|
return e.length > 0 && !e.endsWith(`
|
|
2645
2736
|
`) && (e += `
|
|
2646
2737
|
`), e;
|
|
2647
2738
|
}
|
|
2648
|
-
function fe(
|
|
2649
|
-
const { content:
|
|
2739
|
+
function fe(r) {
|
|
2740
|
+
const { content: t, matches: s, outputLimit: o } = r;
|
|
2650
2741
|
if (s.length === 0)
|
|
2651
2742
|
return { output: "", truncated: !1 };
|
|
2652
2743
|
const e = Ft(s);
|
|
2653
2744
|
let n = "", i = !1;
|
|
2654
2745
|
for (let a = 0; a < e.length; a++) {
|
|
2655
|
-
const c = e[a], l =
|
|
2746
|
+
const c = e[a], l = t.substring(
|
|
2656
2747
|
c.linesOffset[0],
|
|
2657
2748
|
c.linesOffset[1]
|
|
2658
|
-
), u =
|
|
2749
|
+
), u = Bs({
|
|
2659
2750
|
content: l,
|
|
2660
2751
|
startLine: c.lines[0]
|
|
2661
2752
|
}), f = a > 0 ? 2 : 0;
|
|
@@ -2669,12 +2760,12 @@ function fe(t) {
|
|
|
2669
2760
|
return { output: n, truncated: i };
|
|
2670
2761
|
}
|
|
2671
2762
|
const ot = "BEFORE", nt = "AFTER";
|
|
2672
|
-
function
|
|
2673
|
-
const { result:
|
|
2674
|
-
if (
|
|
2763
|
+
function Ls(r) {
|
|
2764
|
+
const { result: t, outputLimit: s } = r;
|
|
2765
|
+
if (t.replace == null) {
|
|
2675
2766
|
const h = fe({
|
|
2676
|
-
content:
|
|
2677
|
-
matches:
|
|
2767
|
+
content: t.search.content,
|
|
2768
|
+
matches: t.search.matches,
|
|
2678
2769
|
outputLimit: s
|
|
2679
2770
|
});
|
|
2680
2771
|
return { output: h.output, truncated: h.truncated };
|
|
@@ -2687,21 +2778,21 @@ function Bs(t) {
|
|
|
2687
2778
|
if (s != null && s < a)
|
|
2688
2779
|
return { output: "", truncated: !0 };
|
|
2689
2780
|
const c = s != null ? s - a : void 0, l = c != null ? Math.floor(c / 2) : void 0, u = fe({
|
|
2690
|
-
content:
|
|
2691
|
-
matches:
|
|
2781
|
+
content: t.search.content,
|
|
2782
|
+
matches: t.search.matches,
|
|
2692
2783
|
outputLimit: l
|
|
2693
2784
|
}), f = c != null ? c - u.output.length : void 0, d = fe({
|
|
2694
|
-
content:
|
|
2695
|
-
matches:
|
|
2785
|
+
content: t.replace.content,
|
|
2786
|
+
matches: t.replace.matches,
|
|
2696
2787
|
outputLimit: f
|
|
2697
2788
|
});
|
|
2698
2789
|
return { output: o + u.output + e + n + d.output + i, truncated: u.truncated || d.truncated };
|
|
2699
2790
|
}
|
|
2700
|
-
function $e(
|
|
2701
|
-
const { result:
|
|
2791
|
+
function $e(r) {
|
|
2792
|
+
const { result: t, rootDir: s, errorsOnly: o } = r;
|
|
2702
2793
|
let e = "";
|
|
2703
|
-
for (let n = 0; n <
|
|
2704
|
-
const i =
|
|
2794
|
+
for (let n = 0; n < t.results.length; n++) {
|
|
2795
|
+
const i = t.results[n], a = k.relative(s, i.filePath), c = e.length > 0 ? 1 : 0;
|
|
2705
2796
|
if (i.error != null) {
|
|
2706
2797
|
const u = a + `
|
|
2707
2798
|
❌ ` + i.error + `
|
|
@@ -2712,7 +2803,7 @@ function $e(t) {
|
|
|
2712
2803
|
}
|
|
2713
2804
|
if (o || i.result == null || i.result.search.matches.length === 0)
|
|
2714
2805
|
continue;
|
|
2715
|
-
const l =
|
|
2806
|
+
const l = Ls({
|
|
2716
2807
|
result: i.result
|
|
2717
2808
|
});
|
|
2718
2809
|
l.output.length > 0 && (c > 0 && (e += `
|
|
@@ -2721,7 +2812,7 @@ function $e(t) {
|
|
|
2721
2812
|
}
|
|
2722
2813
|
return e;
|
|
2723
2814
|
}
|
|
2724
|
-
const
|
|
2815
|
+
const As = m.object({
|
|
2725
2816
|
pattern: m.string().describe("JS RegExp pattern"),
|
|
2726
2817
|
flags: m.string().default("gm").describe('JS RegExp flags. Default: "gm"')
|
|
2727
2818
|
}), Pt = m.object({
|
|
@@ -2729,17 +2820,17 @@ const Ls = m.object({
|
|
|
2729
2820
|
snapshot: ee.optional().describe(
|
|
2730
2821
|
"Filesystem snapshot creation options JSON to automatically create snapshot"
|
|
2731
2822
|
),
|
|
2732
|
-
bulkOperations: m.array(
|
|
2823
|
+
bulkOperations: m.array(As).describe(
|
|
2733
2824
|
"All search patterns to execute; include every pattern here; never split across multiple calls"
|
|
2734
2825
|
),
|
|
2735
2826
|
outputLimit: m.number().int().min(0).max(J).default(Q).describe(
|
|
2736
2827
|
`Maximum output characters. Output exceeding this limit will be truncated. Maximum: ${J}. Default: ${Q}`
|
|
2737
2828
|
)
|
|
2738
2829
|
});
|
|
2739
|
-
async function
|
|
2830
|
+
async function zs(r, t, s) {
|
|
2740
2831
|
let o;
|
|
2741
2832
|
try {
|
|
2742
|
-
o = Pt.parse(
|
|
2833
|
+
o = Pt.parse(r);
|
|
2743
2834
|
} catch (w) {
|
|
2744
2835
|
return {
|
|
2745
2836
|
error: F(w)
|
|
@@ -2764,7 +2855,7 @@ async function As(t, r, s) {
|
|
|
2764
2855
|
} else if (n) {
|
|
2765
2856
|
const w = await ce(
|
|
2766
2857
|
n,
|
|
2767
|
-
|
|
2858
|
+
t,
|
|
2768
2859
|
s
|
|
2769
2860
|
);
|
|
2770
2861
|
if (w.error != null)
|
|
@@ -2789,8 +2880,8 @@ async function As(t, r, s) {
|
|
|
2789
2880
|
limit: a
|
|
2790
2881
|
}).content, rootDir: p, fsSnapshot: l, queryCreated: u, snapshotCreated: f };
|
|
2791
2882
|
}
|
|
2792
|
-
function
|
|
2793
|
-
|
|
2883
|
+
function _s(r, t) {
|
|
2884
|
+
r(
|
|
2794
2885
|
"fs-snapshot-search",
|
|
2795
2886
|
{
|
|
2796
2887
|
title: "Search File Contents in Snapshot",
|
|
@@ -2798,9 +2889,9 @@ function zs(t, r) {
|
|
|
2798
2889
|
inputSchema: Pt.shape
|
|
2799
2890
|
},
|
|
2800
2891
|
async (s, o) => {
|
|
2801
|
-
const e = await
|
|
2892
|
+
const e = await zs(
|
|
2802
2893
|
s,
|
|
2803
|
-
|
|
2894
|
+
t,
|
|
2804
2895
|
o
|
|
2805
2896
|
);
|
|
2806
2897
|
if (e.error != null)
|
|
@@ -2835,10 +2926,10 @@ const Us = m.object({
|
|
|
2835
2926
|
`Maximum output characters. Output exceeding this limit will be truncated. Maximum: ${J}. Default: ${Q}`
|
|
2836
2927
|
)
|
|
2837
2928
|
});
|
|
2838
|
-
async function js(
|
|
2929
|
+
async function js(r, t, s) {
|
|
2839
2930
|
let o;
|
|
2840
2931
|
try {
|
|
2841
|
-
o = Bt.parse(
|
|
2932
|
+
o = Bt.parse(r);
|
|
2842
2933
|
} catch (b) {
|
|
2843
2934
|
return {
|
|
2844
2935
|
error: F(b)
|
|
@@ -2863,7 +2954,7 @@ async function js(t, r, s) {
|
|
|
2863
2954
|
} else if (n) {
|
|
2864
2955
|
const b = await ce(
|
|
2865
2956
|
n,
|
|
2866
|
-
|
|
2957
|
+
t,
|
|
2867
2958
|
s
|
|
2868
2959
|
);
|
|
2869
2960
|
if (b.error != null)
|
|
@@ -2881,14 +2972,14 @@ async function js(t, r, s) {
|
|
|
2881
2972
|
}, g = Date.now(), y = await Ie({
|
|
2882
2973
|
...h,
|
|
2883
2974
|
dryRun: !0
|
|
2884
|
-
}), w =
|
|
2975
|
+
}), w = ls();
|
|
2885
2976
|
c.preparedReplace = {
|
|
2886
2977
|
id: w,
|
|
2887
2978
|
options: h,
|
|
2888
2979
|
rootDir: p,
|
|
2889
2980
|
dateCreated: g
|
|
2890
2981
|
};
|
|
2891
|
-
const
|
|
2982
|
+
const I = $e({
|
|
2892
2983
|
result: y,
|
|
2893
2984
|
rootDir: p
|
|
2894
2985
|
}) + `
|
|
@@ -2896,12 +2987,12 @@ async function js(t, r, s) {
|
|
|
2896
2987
|
Review the output carefully before executing. Call fs-snapshot-replace-execute with replaceId="${w}" exclusively when all replacements are valid; never apply if you detect any problems.`;
|
|
2897
2988
|
return { output: we({
|
|
2898
2989
|
sessionId: s.sessionId,
|
|
2899
|
-
source:
|
|
2990
|
+
source: I,
|
|
2900
2991
|
limit: a
|
|
2901
2992
|
}).content, rootDir: p, fsSnapshot: l, queryCreated: u, snapshotCreated: f };
|
|
2902
2993
|
}
|
|
2903
|
-
function qs(
|
|
2904
|
-
|
|
2994
|
+
function qs(r, t) {
|
|
2995
|
+
r(
|
|
2905
2996
|
"fs-snapshot-replace-prepare",
|
|
2906
2997
|
{
|
|
2907
2998
|
title: "Prepare File Content Replacement",
|
|
@@ -2911,7 +3002,7 @@ function qs(t, r) {
|
|
|
2911
3002
|
async (s, o) => {
|
|
2912
3003
|
const e = await js(
|
|
2913
3004
|
s,
|
|
2914
|
-
|
|
3005
|
+
t,
|
|
2915
3006
|
o
|
|
2916
3007
|
);
|
|
2917
3008
|
if (e.error != null)
|
|
@@ -2933,10 +3024,10 @@ Reminder: use one snapshot covering all target files; include all patterns in th
|
|
|
2933
3024
|
const Lt = m.object({
|
|
2934
3025
|
replaceId: m.string().describe("Replace ID from the END of fs-snapshot-replace-prepare output. NEVER fabricate or guess this value.")
|
|
2935
3026
|
});
|
|
2936
|
-
async function
|
|
3027
|
+
async function Gs(r, t, s) {
|
|
2937
3028
|
let o;
|
|
2938
3029
|
try {
|
|
2939
|
-
o = Lt.parse(
|
|
3030
|
+
o = Lt.parse(r);
|
|
2940
3031
|
} catch (l) {
|
|
2941
3032
|
return {
|
|
2942
3033
|
error: F(l)
|
|
@@ -2966,8 +3057,8 @@ async function _s(t, r, s) {
|
|
|
2966
3057
|
errorsOnly: !0
|
|
2967
3058
|
}) || null };
|
|
2968
3059
|
}
|
|
2969
|
-
function
|
|
2970
|
-
|
|
3060
|
+
function Js(r, t) {
|
|
3061
|
+
r(
|
|
2971
3062
|
"fs-snapshot-replace-execute",
|
|
2972
3063
|
{
|
|
2973
3064
|
title: "Execute Prepared Replacement",
|
|
@@ -2975,9 +3066,9 @@ function Gs(t, r) {
|
|
|
2975
3066
|
inputSchema: Lt.shape
|
|
2976
3067
|
},
|
|
2977
3068
|
async (s, o) => {
|
|
2978
|
-
const e = await
|
|
3069
|
+
const e = await Gs(
|
|
2979
3070
|
s,
|
|
2980
|
-
|
|
3071
|
+
t,
|
|
2981
3072
|
o
|
|
2982
3073
|
);
|
|
2983
3074
|
if (e.error != null)
|
|
@@ -2990,19 +3081,19 @@ ${e.output}`), n;
|
|
|
2990
3081
|
}
|
|
2991
3082
|
);
|
|
2992
3083
|
}
|
|
2993
|
-
function
|
|
2994
|
-
|
|
3084
|
+
function Ws(r, t) {
|
|
3085
|
+
t.list && is(r, t), t.snapshotQueryCreate && us(r, t), t.snapshotCreate && ys(r, t), t.snapshotBrowse && $s(r, t), t.snapshotSearch && _s(r, t), t.snapshotReplace && (qs(r, t), Js(r, t)), console.log(
|
|
2995
3086
|
`File manager:
|
|
2996
|
-
- Working directory: ${k.resolve(
|
|
3087
|
+
- Working directory: ${k.resolve(t.workingDir || "")}
|
|
2997
3088
|
`
|
|
2998
3089
|
);
|
|
2999
3090
|
}
|
|
3000
3091
|
const pe = /* @__PURE__ */ new Map();
|
|
3001
|
-
function W(
|
|
3002
|
-
return pe.has(
|
|
3092
|
+
function W(r) {
|
|
3093
|
+
return pe.has(r) || pe.set(r, {
|
|
3003
3094
|
browsers: /* @__PURE__ */ new Map(),
|
|
3004
3095
|
domSnapshotQueries: /* @__PURE__ */ new Map()
|
|
3005
|
-
}), pe.get(
|
|
3096
|
+
}), pe.get(r);
|
|
3006
3097
|
}
|
|
3007
3098
|
const Me = m.object({
|
|
3008
3099
|
name: m.string().describe(
|
|
@@ -3012,10 +3103,10 @@ const Me = m.object({
|
|
|
3012
3103
|
muteAudio: m.boolean().optional().describe("Mute audio in the browser"),
|
|
3013
3104
|
devTools: m.boolean().optional().describe("Open browser with dev tools")
|
|
3014
3105
|
});
|
|
3015
|
-
async function At(
|
|
3106
|
+
async function At(r, t, s) {
|
|
3016
3107
|
let o;
|
|
3017
3108
|
try {
|
|
3018
|
-
o = Me.parse(
|
|
3109
|
+
o = Me.parse(r);
|
|
3019
3110
|
} catch (l) {
|
|
3020
3111
|
return {
|
|
3021
3112
|
error: F(l)
|
|
@@ -3049,8 +3140,8 @@ async function At(t, r, s) {
|
|
|
3049
3140
|
};
|
|
3050
3141
|
}
|
|
3051
3142
|
}
|
|
3052
|
-
function
|
|
3053
|
-
|
|
3143
|
+
function Ks(r, t) {
|
|
3144
|
+
r(
|
|
3054
3145
|
"playwright-browser-create",
|
|
3055
3146
|
{
|
|
3056
3147
|
title: "Create Browser",
|
|
@@ -3058,17 +3149,17 @@ function Ws(t, r) {
|
|
|
3058
3149
|
inputSchema: Me.shape
|
|
3059
3150
|
},
|
|
3060
3151
|
async (s, o) => {
|
|
3061
|
-
const e = await At(s,
|
|
3152
|
+
const e = await At(s, t, o);
|
|
3062
3153
|
return `Method: playwright-browser-create(${JSON.stringify(s)})
|
|
3063
3154
|
${e.error != null ? `❌ Error: ${e.error}` : `✅ Browser "${e.browserInfo.name}" (${e.browserInfo.browserType}) created successfully`}`;
|
|
3064
3155
|
}
|
|
3065
3156
|
);
|
|
3066
3157
|
}
|
|
3067
3158
|
const zt = m.object({});
|
|
3068
|
-
async function
|
|
3159
|
+
async function Hs(r, t, s) {
|
|
3069
3160
|
let o;
|
|
3070
3161
|
try {
|
|
3071
|
-
o = zt.parse(
|
|
3162
|
+
o = zt.parse(r);
|
|
3072
3163
|
} catch (i) {
|
|
3073
3164
|
return {
|
|
3074
3165
|
error: F(i)
|
|
@@ -3083,8 +3174,8 @@ async function Ks(t, r, s) {
|
|
|
3083
3174
|
browserInfos: Array.from(e.browsers.values())
|
|
3084
3175
|
};
|
|
3085
3176
|
}
|
|
3086
|
-
function
|
|
3087
|
-
|
|
3177
|
+
function Qs(r, t) {
|
|
3178
|
+
r(
|
|
3088
3179
|
"playwright-browser-list",
|
|
3089
3180
|
{
|
|
3090
3181
|
title: "List Browsers",
|
|
@@ -3092,7 +3183,7 @@ function Hs(t, r) {
|
|
|
3092
3183
|
inputSchema: zt.shape
|
|
3093
3184
|
},
|
|
3094
3185
|
async (s, o) => {
|
|
3095
|
-
const e = await
|
|
3186
|
+
const e = await Hs(s, t, o);
|
|
3096
3187
|
if (e.error != null)
|
|
3097
3188
|
return `Method: playwright-browser-list(${JSON.stringify(s)})
|
|
3098
3189
|
❌ Error: ${e.error}`;
|
|
@@ -3104,15 +3195,15 @@ ${n.length === 0 ? "No browsers found" : `Browsers: ${n.join(", ")}`}`;
|
|
|
3104
3195
|
}
|
|
3105
3196
|
);
|
|
3106
3197
|
}
|
|
3107
|
-
const
|
|
3198
|
+
const _t = m.object({
|
|
3108
3199
|
names: m.array(m.string()).optional().describe(
|
|
3109
3200
|
"Names of browsers to close. If not specified, closes all browsers"
|
|
3110
3201
|
)
|
|
3111
3202
|
});
|
|
3112
|
-
async function
|
|
3203
|
+
async function Ys(r, t, s) {
|
|
3113
3204
|
let o;
|
|
3114
3205
|
try {
|
|
3115
|
-
o =
|
|
3206
|
+
o = _t.parse(r);
|
|
3116
3207
|
} catch (l) {
|
|
3117
3208
|
return {
|
|
3118
3209
|
error: F(l)
|
|
@@ -3143,16 +3234,16 @@ async function Qs(t, r, s) {
|
|
|
3143
3234
|
...a.length > 0 && { errors: a }
|
|
3144
3235
|
};
|
|
3145
3236
|
}
|
|
3146
|
-
function
|
|
3147
|
-
|
|
3237
|
+
function Vs(r, t) {
|
|
3238
|
+
r(
|
|
3148
3239
|
"playwright-browser-close",
|
|
3149
3240
|
{
|
|
3150
3241
|
title: "Close Browsers",
|
|
3151
3242
|
description: "Close browsers. Automatically closes all contexts and pages within the browsers",
|
|
3152
|
-
inputSchema:
|
|
3243
|
+
inputSchema: _t.shape
|
|
3153
3244
|
},
|
|
3154
3245
|
async (s, o) => {
|
|
3155
|
-
const e = await
|
|
3246
|
+
const e = await Ys(s, t, o);
|
|
3156
3247
|
if (e.error != null)
|
|
3157
3248
|
return `Method: playwright-browser-close(${JSON.stringify(s)})
|
|
3158
3249
|
❌ Error: ${e.error}`;
|
|
@@ -3184,10 +3275,10 @@ const Te = m.object({
|
|
|
3184
3275
|
height: m.number()
|
|
3185
3276
|
}).optional().describe("Viewport size configuration")
|
|
3186
3277
|
});
|
|
3187
|
-
async function
|
|
3278
|
+
async function Ut(r, t, s) {
|
|
3188
3279
|
let o;
|
|
3189
3280
|
try {
|
|
3190
|
-
o = Te.parse(
|
|
3281
|
+
o = Te.parse(r);
|
|
3191
3282
|
} catch (p) {
|
|
3192
3283
|
return {
|
|
3193
3284
|
error: F(p)
|
|
@@ -3210,7 +3301,7 @@ async function jt(t, r, s) {
|
|
|
3210
3301
|
error: `Browser "${n}" not found`
|
|
3211
3302
|
};
|
|
3212
3303
|
} else if (i) {
|
|
3213
|
-
const p = await At(i,
|
|
3304
|
+
const p = await At(i, t, s);
|
|
3214
3305
|
if (p.error != null)
|
|
3215
3306
|
return {
|
|
3216
3307
|
error: p.error
|
|
@@ -3242,8 +3333,8 @@ async function jt(t, r, s) {
|
|
|
3242
3333
|
};
|
|
3243
3334
|
}
|
|
3244
3335
|
}
|
|
3245
|
-
function
|
|
3246
|
-
|
|
3336
|
+
function Zs(r, t) {
|
|
3337
|
+
r(
|
|
3247
3338
|
"playwright-context-create",
|
|
3248
3339
|
{
|
|
3249
3340
|
title: "Create Browser Context",
|
|
@@ -3251,7 +3342,7 @@ function Vs(t, r) {
|
|
|
3251
3342
|
inputSchema: Te.shape
|
|
3252
3343
|
},
|
|
3253
3344
|
async (s, o) => {
|
|
3254
|
-
const e = await
|
|
3345
|
+
const e = await Ut(s, t, o);
|
|
3255
3346
|
if (e.error != null)
|
|
3256
3347
|
return `Method: playwright-context-create(${JSON.stringify(s)})
|
|
3257
3348
|
❌ Error: ${e.error}`;
|
|
@@ -3262,15 +3353,15 @@ function Vs(t, r) {
|
|
|
3262
3353
|
}
|
|
3263
3354
|
);
|
|
3264
3355
|
}
|
|
3265
|
-
const
|
|
3356
|
+
const jt = m.object({
|
|
3266
3357
|
browserName: m.string().optional().describe(
|
|
3267
3358
|
"Name of browser to list contexts from. If not specified, lists contexts from all browsers"
|
|
3268
3359
|
)
|
|
3269
3360
|
});
|
|
3270
|
-
async function
|
|
3361
|
+
async function Xs(r, t, s) {
|
|
3271
3362
|
let o;
|
|
3272
3363
|
try {
|
|
3273
|
-
o =
|
|
3364
|
+
o = jt.parse(r);
|
|
3274
3365
|
} catch (a) {
|
|
3275
3366
|
return {
|
|
3276
3367
|
error: F(a)
|
|
@@ -3304,16 +3395,16 @@ async function Zs(t, r, s) {
|
|
|
3304
3395
|
contextsByBrowser: i
|
|
3305
3396
|
};
|
|
3306
3397
|
}
|
|
3307
|
-
function
|
|
3308
|
-
|
|
3398
|
+
function eo(r, t) {
|
|
3399
|
+
r(
|
|
3309
3400
|
"playwright-context-list",
|
|
3310
3401
|
{
|
|
3311
3402
|
title: "List Browser Contexts",
|
|
3312
3403
|
description: "List active browser contexts",
|
|
3313
|
-
inputSchema:
|
|
3404
|
+
inputSchema: jt.shape
|
|
3314
3405
|
},
|
|
3315
3406
|
async (s, o) => {
|
|
3316
|
-
const e = await
|
|
3407
|
+
const e = await Xs(s, t, o);
|
|
3317
3408
|
if ("error" in e)
|
|
3318
3409
|
return `Method: playwright-context-list(${JSON.stringify(s)})
|
|
3319
3410
|
❌ Error: ${e.error}`;
|
|
@@ -3326,7 +3417,7 @@ function Xs(t, r) {
|
|
|
3326
3417
|
}
|
|
3327
3418
|
);
|
|
3328
3419
|
}
|
|
3329
|
-
const
|
|
3420
|
+
const qt = m.object({
|
|
3330
3421
|
names: m.array(m.string()).optional().describe(
|
|
3331
3422
|
"Names of contexts to close. If not specified, closes all contexts"
|
|
3332
3423
|
),
|
|
@@ -3334,10 +3425,10 @@ const _t = m.object({
|
|
|
3334
3425
|
"Name of browser to close contexts from. If not specified, searches all browsers"
|
|
3335
3426
|
)
|
|
3336
3427
|
});
|
|
3337
|
-
async function
|
|
3428
|
+
async function to(r, t, s) {
|
|
3338
3429
|
let o;
|
|
3339
3430
|
try {
|
|
3340
|
-
o =
|
|
3431
|
+
o = qt.parse(r);
|
|
3341
3432
|
} catch (u) {
|
|
3342
3433
|
return {
|
|
3343
3434
|
error: F(u)
|
|
@@ -3388,16 +3479,16 @@ async function eo(t, r, s) {
|
|
|
3388
3479
|
...c.length > 0 && { errors: c }
|
|
3389
3480
|
};
|
|
3390
3481
|
}
|
|
3391
|
-
function
|
|
3392
|
-
|
|
3482
|
+
function ro(r, t) {
|
|
3483
|
+
r(
|
|
3393
3484
|
"playwright-context-close",
|
|
3394
3485
|
{
|
|
3395
3486
|
title: "Close Browser Contexts",
|
|
3396
3487
|
description: "Close browser contexts. Automatically closes all pages within the contexts",
|
|
3397
|
-
inputSchema:
|
|
3488
|
+
inputSchema: qt.shape
|
|
3398
3489
|
},
|
|
3399
3490
|
async (s, o) => {
|
|
3400
|
-
const e = await
|
|
3491
|
+
const e = await to(s, t, o);
|
|
3401
3492
|
if ("error" in e)
|
|
3402
3493
|
return `Method: playwright-context-close(${JSON.stringify(s)})
|
|
3403
3494
|
❌ Error: ${e.error}`;
|
|
@@ -3414,8 +3505,8 @@ ${n.join(`
|
|
|
3414
3505
|
}
|
|
3415
3506
|
);
|
|
3416
3507
|
}
|
|
3417
|
-
function
|
|
3418
|
-
class
|
|
3508
|
+
function so() {
|
|
3509
|
+
class r {
|
|
3419
3510
|
prevId = 0;
|
|
3420
3511
|
objectToId = /* @__PURE__ */ new WeakMap();
|
|
3421
3512
|
idToObject = /* @__PURE__ */ new Map();
|
|
@@ -3437,27 +3528,27 @@ function ro() {
|
|
|
3437
3528
|
return u ?? (this.idToObject.delete(c), null);
|
|
3438
3529
|
}
|
|
3439
3530
|
}
|
|
3440
|
-
function
|
|
3531
|
+
function t(a, c, l) {
|
|
3441
3532
|
let u = null;
|
|
3442
3533
|
for (let f = 0, d = c.length; f < d; f++) {
|
|
3443
|
-
const p = c[f], h = a(p), g = h == null ? null :
|
|
3534
|
+
const p = c[f], h = a(p), g = h == null ? null : t(a, h, l), y = l(p, g);
|
|
3444
3535
|
y != null && (u == null && (u = []), u.push(y));
|
|
3445
3536
|
}
|
|
3446
3537
|
return u;
|
|
3447
3538
|
}
|
|
3448
3539
|
function s(a) {
|
|
3449
|
-
const { getId: c, getChilds: l, rootNodes: u, createSnapshotNode: f } = a, d = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), g =
|
|
3540
|
+
const { getId: c, getChilds: l, rootNodes: u, createSnapshotNode: f } = a, d = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), g = t(
|
|
3450
3541
|
l,
|
|
3451
3542
|
u,
|
|
3452
|
-
(w,
|
|
3453
|
-
const E = f(w,
|
|
3543
|
+
(w, I) => {
|
|
3544
|
+
const E = f(w, I);
|
|
3454
3545
|
if (w != null && E != null) {
|
|
3455
3546
|
const b = c(w);
|
|
3456
3547
|
d.set(b, E), p.set(E, b);
|
|
3457
3548
|
}
|
|
3458
|
-
return E != null &&
|
|
3549
|
+
return E != null && I != null && h.set(
|
|
3459
3550
|
p.get(E),
|
|
3460
|
-
|
|
3551
|
+
I.map((b) => p.get(b))
|
|
3461
3552
|
), E;
|
|
3462
3553
|
}
|
|
3463
3554
|
), y = f(null, g);
|
|
@@ -3490,7 +3581,7 @@ function ro() {
|
|
|
3490
3581
|
};
|
|
3491
3582
|
};
|
|
3492
3583
|
}
|
|
3493
|
-
const n = new
|
|
3584
|
+
const n = new r();
|
|
3494
3585
|
function i(a) {
|
|
3495
3586
|
const c = e(a);
|
|
3496
3587
|
return s({
|
|
@@ -3502,7 +3593,7 @@ function ro() {
|
|
|
3502
3593
|
}
|
|
3503
3594
|
window.__mcp_playwright_tool_tx4byhar35_createDomSnapshotTreeRawDom = i;
|
|
3504
3595
|
}
|
|
3505
|
-
const
|
|
3596
|
+
const oo = `(function (){function __name(fn){return fn};${so.toString()}; setupPageGlobals();})()`, ve = m.object({
|
|
3506
3597
|
contextName: m.string().optional().describe("Name of previously created context, to use"),
|
|
3507
3598
|
context: Te.optional().describe(
|
|
3508
3599
|
"Context creation options JSON to automatically create context"
|
|
@@ -3511,10 +3602,10 @@ const so = `(function (){function __name(fn){return fn};${ro.toString()}; setupP
|
|
|
3511
3602
|
"Unique name for the page. Recommended format: kebab-case-1, kebab-case-2, ..."
|
|
3512
3603
|
)
|
|
3513
3604
|
});
|
|
3514
|
-
async function Gt(
|
|
3605
|
+
async function Gt(r, t, s) {
|
|
3515
3606
|
let o;
|
|
3516
3607
|
try {
|
|
3517
|
-
o =
|
|
3608
|
+
o = ve.parse(r);
|
|
3518
3609
|
} catch (f) {
|
|
3519
3610
|
return {
|
|
3520
3611
|
error: F(f)
|
|
@@ -3542,7 +3633,7 @@ async function Gt(t, r, s) {
|
|
|
3542
3633
|
error: `Context "${n}" not found`
|
|
3543
3634
|
};
|
|
3544
3635
|
} else if (i) {
|
|
3545
|
-
const f = await
|
|
3636
|
+
const f = await Ut(i, t, s);
|
|
3546
3637
|
if (f.error != null)
|
|
3547
3638
|
return {
|
|
3548
3639
|
error: f.error
|
|
@@ -3554,7 +3645,7 @@ async function Gt(t, r, s) {
|
|
|
3554
3645
|
};
|
|
3555
3646
|
try {
|
|
3556
3647
|
const f = await u.context.newPage();
|
|
3557
|
-
await f.addInitScript(
|
|
3648
|
+
await f.addInitScript(oo), await f.goto("about:blank");
|
|
3558
3649
|
const d = {
|
|
3559
3650
|
contextInfo: u,
|
|
3560
3651
|
name: e,
|
|
@@ -3572,16 +3663,16 @@ async function Gt(t, r, s) {
|
|
|
3572
3663
|
};
|
|
3573
3664
|
}
|
|
3574
3665
|
}
|
|
3575
|
-
function
|
|
3576
|
-
|
|
3666
|
+
function no(r, t) {
|
|
3667
|
+
r(
|
|
3577
3668
|
"playwright-page-create",
|
|
3578
3669
|
{
|
|
3579
3670
|
title: "Create Page",
|
|
3580
3671
|
description: "Create a new page. Prefer page-goto if you need to immediately create a page and navigate",
|
|
3581
|
-
inputSchema:
|
|
3672
|
+
inputSchema: ve.shape
|
|
3582
3673
|
},
|
|
3583
3674
|
async (s, o) => {
|
|
3584
|
-
const e = await Gt(s,
|
|
3675
|
+
const e = await Gt(s, t, o);
|
|
3585
3676
|
if (e.error != null)
|
|
3586
3677
|
return `Method: playwright-page-create(${JSON.stringify(s)})
|
|
3587
3678
|
❌ Error: ${e.error}`;
|
|
@@ -3601,10 +3692,10 @@ const Jt = m.object({
|
|
|
3601
3692
|
"Name of browser to search in. If not specified, searches all browsers"
|
|
3602
3693
|
)
|
|
3603
3694
|
});
|
|
3604
|
-
async function
|
|
3695
|
+
async function io(r, t, s) {
|
|
3605
3696
|
let o;
|
|
3606
3697
|
try {
|
|
3607
|
-
o = Jt.parse(
|
|
3698
|
+
o = Jt.parse(r);
|
|
3608
3699
|
} catch (c) {
|
|
3609
3700
|
return {
|
|
3610
3701
|
error: F(c)
|
|
@@ -3665,8 +3756,8 @@ async function no(t, r, s) {
|
|
|
3665
3756
|
pagesByContext: a
|
|
3666
3757
|
};
|
|
3667
3758
|
}
|
|
3668
|
-
function
|
|
3669
|
-
|
|
3759
|
+
function ao(r, t) {
|
|
3760
|
+
r(
|
|
3670
3761
|
"playwright-page-list",
|
|
3671
3762
|
{
|
|
3672
3763
|
title: "List Pages",
|
|
@@ -3674,7 +3765,7 @@ function io(t, r) {
|
|
|
3674
3765
|
inputSchema: Jt.shape
|
|
3675
3766
|
},
|
|
3676
3767
|
async (s, o) => {
|
|
3677
|
-
const e = await
|
|
3768
|
+
const e = await io(s, t, o);
|
|
3678
3769
|
if ("error" in e)
|
|
3679
3770
|
return `Method: playwright-page-list(${JSON.stringify(s)})
|
|
3680
3771
|
❌ Error: ${e.error}`;
|
|
@@ -3696,10 +3787,10 @@ const Wt = m.object({
|
|
|
3696
3787
|
"Name of browser to search in. If not specified, searches all browsers"
|
|
3697
3788
|
)
|
|
3698
3789
|
});
|
|
3699
|
-
async function
|
|
3790
|
+
async function lo(r, t, s) {
|
|
3700
3791
|
let o;
|
|
3701
3792
|
try {
|
|
3702
|
-
o = Wt.parse(
|
|
3793
|
+
o = Wt.parse(r);
|
|
3703
3794
|
} catch (f) {
|
|
3704
3795
|
return {
|
|
3705
3796
|
error: F(f)
|
|
@@ -3774,8 +3865,8 @@ async function ao(t, r, s) {
|
|
|
3774
3865
|
...l.length > 0 && { errors: l }
|
|
3775
3866
|
};
|
|
3776
3867
|
}
|
|
3777
|
-
function
|
|
3778
|
-
|
|
3868
|
+
function co(r, t) {
|
|
3869
|
+
r(
|
|
3779
3870
|
"playwright-page-close",
|
|
3780
3871
|
{
|
|
3781
3872
|
title: "Close Pages",
|
|
@@ -3783,7 +3874,7 @@ function lo(t, r) {
|
|
|
3783
3874
|
inputSchema: Wt.shape
|
|
3784
3875
|
},
|
|
3785
3876
|
async (s, o) => {
|
|
3786
|
-
const e = await
|
|
3877
|
+
const e = await lo(s, t, o);
|
|
3787
3878
|
if ("error" in e)
|
|
3788
3879
|
return `Method: playwright-page-close(${JSON.stringify(s)})
|
|
3789
3880
|
❌ Error: ${e.error}`;
|
|
@@ -3796,7 +3887,7 @@ ${n.join(`
|
|
|
3796
3887
|
}
|
|
3797
3888
|
const Kt = m.object({
|
|
3798
3889
|
pageName: m.string().optional().describe("Name of previously created page to navigate"),
|
|
3799
|
-
page:
|
|
3890
|
+
page: ve.optional().describe(
|
|
3800
3891
|
"Page creation options JSON to automatically create page"
|
|
3801
3892
|
),
|
|
3802
3893
|
url: m.string().describe("URL to navigate to"),
|
|
@@ -3809,10 +3900,10 @@ const Kt = m.object({
|
|
|
3809
3900
|
- 'commit': network response received and document started loading`
|
|
3810
3901
|
)
|
|
3811
3902
|
});
|
|
3812
|
-
async function
|
|
3903
|
+
async function uo(r, t, s) {
|
|
3813
3904
|
let o;
|
|
3814
3905
|
try {
|
|
3815
|
-
o = Kt.parse(
|
|
3906
|
+
o = Kt.parse(r);
|
|
3816
3907
|
} catch (h) {
|
|
3817
3908
|
return {
|
|
3818
3909
|
error: F(h)
|
|
@@ -3843,7 +3934,7 @@ async function co(t, r, s) {
|
|
|
3843
3934
|
error: `Page "${e}" not found`
|
|
3844
3935
|
};
|
|
3845
3936
|
} else if (n) {
|
|
3846
|
-
const h = await Gt(n,
|
|
3937
|
+
const h = await Gt(n, t, s);
|
|
3847
3938
|
if (h.error != null)
|
|
3848
3939
|
return {
|
|
3849
3940
|
error: h.error
|
|
@@ -3877,8 +3968,8 @@ async function co(t, r, s) {
|
|
|
3877
3968
|
};
|
|
3878
3969
|
}
|
|
3879
3970
|
}
|
|
3880
|
-
function
|
|
3881
|
-
|
|
3971
|
+
function fo(r, t) {
|
|
3972
|
+
r(
|
|
3882
3973
|
"playwright-page-goto",
|
|
3883
3974
|
{
|
|
3884
3975
|
title: "Navigate Page",
|
|
@@ -3886,7 +3977,7 @@ function uo(t, r) {
|
|
|
3886
3977
|
inputSchema: Kt.shape
|
|
3887
3978
|
},
|
|
3888
3979
|
async (s, o) => {
|
|
3889
|
-
const e = await
|
|
3980
|
+
const e = await uo(s, t, o);
|
|
3890
3981
|
if (e.error != null)
|
|
3891
3982
|
return `Method: playwright-page-goto(${JSON.stringify(s)})
|
|
3892
3983
|
❌ Error: ${e.error}`;
|
|
@@ -3899,16 +3990,16 @@ function uo(t, r) {
|
|
|
3899
3990
|
}
|
|
3900
3991
|
);
|
|
3901
3992
|
}
|
|
3902
|
-
const
|
|
3993
|
+
const Ce = m.object({
|
|
3903
3994
|
name: m.string().describe(
|
|
3904
3995
|
"Unique name for the DOM snapshot query. Recommended format: kebab-case-1, kebab-case-2, ..."
|
|
3905
3996
|
),
|
|
3906
3997
|
cssSelector: m.string().describe("CSS selector to capture page content")
|
|
3907
3998
|
});
|
|
3908
|
-
async function Ht(
|
|
3999
|
+
async function Ht(r, t, s) {
|
|
3909
4000
|
let o;
|
|
3910
4001
|
try {
|
|
3911
|
-
o =
|
|
4002
|
+
o = Ce.parse(r);
|
|
3912
4003
|
} catch (c) {
|
|
3913
4004
|
return {
|
|
3914
4005
|
error: F(c)
|
|
@@ -3927,23 +4018,23 @@ async function Ht(t, r, s) {
|
|
|
3927
4018
|
snapshotQuery: a
|
|
3928
4019
|
};
|
|
3929
4020
|
}
|
|
3930
|
-
function
|
|
3931
|
-
|
|
4021
|
+
function po(r, t) {
|
|
4022
|
+
r(
|
|
3932
4023
|
"playwright-dom-snapshot-query-create",
|
|
3933
4024
|
{
|
|
3934
4025
|
title: "Create DOM Snapshot Query",
|
|
3935
4026
|
description: "Create a DOM snapshot query. Prefer dom-snapshot-browse if you need to immediately create a query and snapshot and browse it",
|
|
3936
|
-
inputSchema:
|
|
4027
|
+
inputSchema: Ce.shape
|
|
3937
4028
|
},
|
|
3938
4029
|
async (s, o) => {
|
|
3939
|
-
const e = await Ht(s,
|
|
4030
|
+
const e = await Ht(s, t, o);
|
|
3940
4031
|
return e.error != null ? `Method: playwright-dom-snapshot-query-create(${JSON.stringify(s)})
|
|
3941
4032
|
❌ Error: ${e.error}` : `Method: playwright-dom-snapshot-query-create(${JSON.stringify(s)})
|
|
3942
4033
|
✅ DOM snapshot query "${e.snapshotQuery.name}" created successfully`;
|
|
3943
4034
|
}
|
|
3944
4035
|
);
|
|
3945
4036
|
}
|
|
3946
|
-
function
|
|
4037
|
+
function ho(r) {
|
|
3947
4038
|
return function(s, o) {
|
|
3948
4039
|
let e, n = 0;
|
|
3949
4040
|
const i = o ? o.length : 0;
|
|
@@ -3979,8 +4070,8 @@ function po(t) {
|
|
|
3979
4070
|
};
|
|
3980
4071
|
};
|
|
3981
4072
|
}
|
|
3982
|
-
function
|
|
3983
|
-
const s = le(
|
|
4073
|
+
function mo(r, t) {
|
|
4074
|
+
const s = le(t), o = s.getChilds(s.root), e = Et({
|
|
3984
4075
|
getId: (n) => {
|
|
3985
4076
|
const i = s.getId(n);
|
|
3986
4077
|
if (i == null)
|
|
@@ -3990,7 +4081,7 @@ function ho(t, r) {
|
|
|
3990
4081
|
return i;
|
|
3991
4082
|
},
|
|
3992
4083
|
getChilds: (n) => s.getChilds(n),
|
|
3993
|
-
createSnapshotNode:
|
|
4084
|
+
createSnapshotNode: ho(),
|
|
3994
4085
|
rootNodes: o ?? []
|
|
3995
4086
|
});
|
|
3996
4087
|
return le(e);
|
|
@@ -3998,17 +4089,17 @@ function ho(t, r) {
|
|
|
3998
4089
|
const Ee = m.object({
|
|
3999
4090
|
pageName: m.string().describe("Name of previously created page, to create snapshot from"),
|
|
4000
4091
|
queryName: m.string().optional().describe("Name of previously created DOM snapshot query, to use"),
|
|
4001
|
-
query:
|
|
4092
|
+
query: Ce.optional().describe(
|
|
4002
4093
|
"DOM snapshot query creation options JSON to automatically create query"
|
|
4003
4094
|
),
|
|
4004
4095
|
name: m.string().describe(
|
|
4005
4096
|
"Unique name for the DOM snapshot. Recommended format: kebab-case-1, kebab-case-2, ..."
|
|
4006
4097
|
)
|
|
4007
4098
|
});
|
|
4008
|
-
async function Qt(
|
|
4099
|
+
async function Qt(r, t, s) {
|
|
4009
4100
|
let o;
|
|
4010
4101
|
try {
|
|
4011
|
-
o = Ee.parse(
|
|
4102
|
+
o = Ee.parse(r);
|
|
4012
4103
|
} catch (d) {
|
|
4013
4104
|
return {
|
|
4014
4105
|
error: F(d)
|
|
@@ -4048,7 +4139,7 @@ async function Qt(t, r, s) {
|
|
|
4048
4139
|
} else if (i) {
|
|
4049
4140
|
const d = await Ht(
|
|
4050
4141
|
i,
|
|
4051
|
-
|
|
4142
|
+
t,
|
|
4052
4143
|
s
|
|
4053
4144
|
);
|
|
4054
4145
|
if (d.error != null)
|
|
@@ -4066,17 +4157,17 @@ async function Qt(t, r, s) {
|
|
|
4066
4157
|
const w = window.__mcp_playwright_tool_tx4byhar35_createDomSnapshotTreeRawDom;
|
|
4067
4158
|
if (!w)
|
|
4068
4159
|
throw new Error("DOM snapshot global function not initialized");
|
|
4069
|
-
const
|
|
4160
|
+
const I = w(y);
|
|
4070
4161
|
return {
|
|
4071
|
-
idToNode: Array.from(
|
|
4072
|
-
idToChildIds: Array.from(
|
|
4162
|
+
idToNode: Array.from(I.idToNode.entries()),
|
|
4163
|
+
idToChildIds: Array.from(I.idToChildIds.entries())
|
|
4073
4164
|
};
|
|
4074
4165
|
},
|
|
4075
4166
|
u
|
|
4076
4167
|
), p = {
|
|
4077
4168
|
idToNode: new Map(d.idToNode),
|
|
4078
4169
|
idToChildIds: new Map(d.idToChildIds)
|
|
4079
|
-
}, h =
|
|
4170
|
+
}, h = mo(u, p), g = {
|
|
4080
4171
|
name: a,
|
|
4081
4172
|
query: u,
|
|
4082
4173
|
tree: h
|
|
@@ -4091,8 +4182,8 @@ async function Qt(t, r, s) {
|
|
|
4091
4182
|
};
|
|
4092
4183
|
}
|
|
4093
4184
|
}
|
|
4094
|
-
function
|
|
4095
|
-
|
|
4185
|
+
function go(r, t) {
|
|
4186
|
+
r(
|
|
4096
4187
|
"playwright-dom-snapshot-create",
|
|
4097
4188
|
{
|
|
4098
4189
|
title: "Create DOM Snapshot",
|
|
@@ -4100,7 +4191,7 @@ function mo(t, r) {
|
|
|
4100
4191
|
inputSchema: Ee.shape
|
|
4101
4192
|
},
|
|
4102
4193
|
async (s, o) => {
|
|
4103
|
-
const e = await Qt(s,
|
|
4194
|
+
const e = await Qt(s, t, o);
|
|
4104
4195
|
if (e.error != null)
|
|
4105
4196
|
return `Method: playwright-dom-snapshot-create(${JSON.stringify(s)})
|
|
4106
4197
|
❌ Error: ${e.error}`;
|
|
@@ -4111,19 +4202,19 @@ function mo(t, r) {
|
|
|
4111
4202
|
}
|
|
4112
4203
|
);
|
|
4113
4204
|
}
|
|
4114
|
-
class
|
|
4205
|
+
class wo {
|
|
4115
4206
|
tokens = 20;
|
|
4116
|
-
getReportText = (
|
|
4207
|
+
getReportText = (t) => ({
|
|
4117
4208
|
indent: !0,
|
|
4118
|
-
textOpen: `[${
|
|
4209
|
+
textOpen: `[${t.indexRange[0]}-${t.indexRange[1]}] see more ${t.countMatched} matched ${t.tokensGrouped} tokens`,
|
|
4119
4210
|
textClose: null
|
|
4120
4211
|
});
|
|
4121
|
-
add = (
|
|
4212
|
+
add = (t, s, o) => t == null ? {
|
|
4122
4213
|
indexRange: [o, o],
|
|
4123
4214
|
countGrouped: 1,
|
|
4124
4215
|
countMatched: s.countMatched,
|
|
4125
4216
|
tokensGrouped: s.tokens
|
|
4126
|
-
} : (
|
|
4217
|
+
} : (t.indexRange[1] = o, t.countGrouped += 1, t.countMatched += s.countMatched, t.tokensGrouped += s.tokens, t);
|
|
4127
4218
|
}
|
|
4128
4219
|
const Yt = m.object({
|
|
4129
4220
|
snapshotName: m.string().optional().describe("Name of previously created DOM snapshot, to use"),
|
|
@@ -4145,10 +4236,10 @@ const Yt = m.object({
|
|
|
4145
4236
|
// maxCountGroup: z.number().default(10).describe('Maximum items per group'),
|
|
4146
4237
|
// maxTokensGroup: z.number().default(1000).describe('Maximum tokens per group'),
|
|
4147
4238
|
});
|
|
4148
|
-
async function
|
|
4239
|
+
async function yo(r, t, s) {
|
|
4149
4240
|
let o;
|
|
4150
4241
|
try {
|
|
4151
|
-
o = Yt.parse(
|
|
4242
|
+
o = Yt.parse(r);
|
|
4152
4243
|
} catch (g) {
|
|
4153
4244
|
return {
|
|
4154
4245
|
error: F(g)
|
|
@@ -4191,7 +4282,7 @@ async function wo(t, r, s) {
|
|
|
4191
4282
|
} else if (n) {
|
|
4192
4283
|
const g = await Qt(
|
|
4193
4284
|
n,
|
|
4194
|
-
|
|
4285
|
+
t,
|
|
4195
4286
|
s
|
|
4196
4287
|
);
|
|
4197
4288
|
if (g.error != null)
|
|
@@ -4216,7 +4307,7 @@ async function wo(t, r, s) {
|
|
|
4216
4307
|
maxTokensGroup: u
|
|
4217
4308
|
}
|
|
4218
4309
|
},
|
|
4219
|
-
indexRangeGroupStrategy: new
|
|
4310
|
+
indexRangeGroupStrategy: new wo()
|
|
4220
4311
|
}), w = Ot(y);
|
|
4221
4312
|
return {
|
|
4222
4313
|
domSnapshot: d,
|
|
@@ -4232,8 +4323,8 @@ async function wo(t, r, s) {
|
|
|
4232
4323
|
};
|
|
4233
4324
|
}
|
|
4234
4325
|
}
|
|
4235
|
-
function
|
|
4236
|
-
|
|
4326
|
+
function bo(r, t) {
|
|
4327
|
+
r(
|
|
4237
4328
|
"playwright-dom-snapshot-browse",
|
|
4238
4329
|
{
|
|
4239
4330
|
title: "Browse DOM Snapshot",
|
|
@@ -4241,7 +4332,7 @@ function yo(t, r) {
|
|
|
4241
4332
|
inputSchema: Yt.shape
|
|
4242
4333
|
},
|
|
4243
4334
|
async (s, o) => {
|
|
4244
|
-
const e = await
|
|
4335
|
+
const e = await yo(s, t, o);
|
|
4245
4336
|
if (e.error != null)
|
|
4246
4337
|
return `Method: playwright-dom-snapshot-browse(${JSON.stringify(s)})
|
|
4247
4338
|
❌ Error: ${e.error}`;
|
|
@@ -4262,14 +4353,14 @@ ${e.report}`, n;
|
|
|
4262
4353
|
}
|
|
4263
4354
|
);
|
|
4264
4355
|
}
|
|
4265
|
-
function
|
|
4266
|
-
|
|
4356
|
+
function So(r, t) {
|
|
4357
|
+
t.browserCreate && Ks(r, t), t.browserList && Qs(r, t), t.browserClose && Vs(r, t), t.contextCreate && Zs(r, t), t.contextList && eo(r, t), t.contextClose && ro(r, t), t.pageCreate && no(r, t), t.pageList && ao(r, t), t.pageClose && co(r, t), t.pageGoto && fo(r, t), t.domSnapshotQueryCreate && po(r, t), t.domSnapshotCreate && go(r, t), t.domSnapshotBrowse && bo(r, t), console.log("Playwright manager");
|
|
4267
4358
|
}
|
|
4268
|
-
function
|
|
4269
|
-
const { logFilePath:
|
|
4359
|
+
function xo(r) {
|
|
4360
|
+
const { logFilePath: t } = r;
|
|
4270
4361
|
return async function(o, e, n, i) {
|
|
4271
4362
|
await ie({
|
|
4272
|
-
logFilePath:
|
|
4363
|
+
logFilePath: t,
|
|
4273
4364
|
message: "ERROR",
|
|
4274
4365
|
data: {
|
|
4275
4366
|
request: {
|
|
@@ -4292,19 +4383,19 @@ const it = [
|
|
|
4292
4383
|
"flemist-mcp.config.json5",
|
|
4293
4384
|
"flemist-mcp.config.yaml"
|
|
4294
4385
|
];
|
|
4295
|
-
async function
|
|
4296
|
-
const
|
|
4386
|
+
async function Io(r) {
|
|
4387
|
+
const t = k.resolve(r);
|
|
4297
4388
|
for (let s = 0, o = it.length; s < o; s++) {
|
|
4298
|
-
const e = it[s], n = k.join(
|
|
4389
|
+
const e = it[s], n = k.join(t, e);
|
|
4299
4390
|
try {
|
|
4300
|
-
await
|
|
4391
|
+
await U.promises.stat(n);
|
|
4301
4392
|
} catch {
|
|
4302
4393
|
continue;
|
|
4303
4394
|
}
|
|
4304
4395
|
console.log(`Loading configuration from: ${n}`);
|
|
4305
4396
|
let i;
|
|
4306
4397
|
try {
|
|
4307
|
-
i = await
|
|
4398
|
+
i = await U.promises.readFile(n, "utf-8");
|
|
4308
4399
|
} catch (c) {
|
|
4309
4400
|
throw new Error(`MCP Error: Failed to read config file: ${n}
|
|
4310
4401
|
|
|
@@ -4324,14 +4415,14 @@ ${c instanceof Error ? c.message : String(c)}`);
|
|
|
4324
4415
|
${c instanceof Error ? c.message : String(c)}`);
|
|
4325
4416
|
}
|
|
4326
4417
|
}
|
|
4327
|
-
throw new Error(`MCP Error: No configuration file found in: ${
|
|
4418
|
+
throw new Error(`MCP Error: No configuration file found in: ${t}
|
|
4328
4419
|
|
|
4329
4420
|
Expected one of:
|
|
4330
4421
|
- flemist-mcp.config.json
|
|
4331
4422
|
- flemist-mcp.config.json5
|
|
4332
4423
|
- flemist-mcp.config.yaml`);
|
|
4333
4424
|
}
|
|
4334
|
-
const
|
|
4425
|
+
const $o = {
|
|
4335
4426
|
logDir: "tmp/mcp-project-tools/logs",
|
|
4336
4427
|
tools: {
|
|
4337
4428
|
processManager: {
|
|
@@ -4372,27 +4463,27 @@ const Io = {
|
|
|
4372
4463
|
}
|
|
4373
4464
|
}
|
|
4374
4465
|
};
|
|
4375
|
-
async function
|
|
4376
|
-
const
|
|
4466
|
+
async function Mo(r) {
|
|
4467
|
+
const t = k.resolve(r), s = await Io(t), o = k.join(t, ".flemist-mcpignore");
|
|
4377
4468
|
try {
|
|
4378
|
-
await
|
|
4469
|
+
await U.promises.stat(o);
|
|
4379
4470
|
} catch {
|
|
4380
4471
|
throw new Error(`MCP Error: .flemist-mcpignore file not found in project directory.
|
|
4381
4472
|
|
|
4382
|
-
Create .flemist-mcpignore file in: ${
|
|
4473
|
+
Create .flemist-mcpignore file in: ${t}
|
|
4383
4474
|
|
|
4384
4475
|
This file contains glob patterns for files/directories to exclude from MCP operations.`);
|
|
4385
4476
|
}
|
|
4386
|
-
const e = dr(
|
|
4477
|
+
const e = dr($o, s, {
|
|
4387
4478
|
arrayMerge(n, i) {
|
|
4388
4479
|
return i;
|
|
4389
4480
|
}
|
|
4390
4481
|
});
|
|
4391
4482
|
return e.tools?.processManager && (e.tools.processManager.workingDir = k.resolve(
|
|
4392
|
-
|
|
4483
|
+
t,
|
|
4393
4484
|
e.tools.processManager.workingDir || ""
|
|
4394
4485
|
)), e.tools?.fsManager && (e.tools.fsManager.workingDir = k.resolve(
|
|
4395
|
-
|
|
4486
|
+
t,
|
|
4396
4487
|
e.tools.fsManager.workingDir || ""
|
|
4397
4488
|
)), e.tools?.fsManager && (e.tools.fsManager.globsExclude = [
|
|
4398
4489
|
{
|
|
@@ -4402,34 +4493,34 @@ This file contains glob patterns for files/directories to exclude from MCP opera
|
|
|
4402
4493
|
},
|
|
4403
4494
|
...e.tools.fsManager.globsExclude || []
|
|
4404
4495
|
]), e.tools.fsManager?.globsExclude?.forEach((n, i, a) => {
|
|
4405
|
-
n.valueType === "file-contains-patterns" && (a[i].value = k.resolve(
|
|
4406
|
-
}), e.logDir = k.resolve(
|
|
4496
|
+
n.valueType === "file-contains-patterns" && (a[i].value = k.resolve(t, n.value));
|
|
4497
|
+
}), e.logDir = k.resolve(t, e.logDir), e;
|
|
4407
4498
|
}
|
|
4408
4499
|
function Vt() {
|
|
4409
4500
|
return `mcp_${(/* @__PURE__ */ new Date()).toISOString().substring(0, 19).replace(/T/, "_").replace(/:/g, "-")}.log`;
|
|
4410
4501
|
}
|
|
4411
|
-
function
|
|
4412
|
-
const
|
|
4413
|
-
return
|
|
4502
|
+
function To(r) {
|
|
4503
|
+
const t = ne(), s = vo();
|
|
4504
|
+
return t.use(s), t;
|
|
4414
4505
|
}
|
|
4415
|
-
function
|
|
4416
|
-
const
|
|
4417
|
-
return
|
|
4506
|
+
function vo(r) {
|
|
4507
|
+
const t = ne.Router();
|
|
4508
|
+
return t.use((s, o, e) => {
|
|
4418
4509
|
s.method === "OPTIONS" ? o.status(403).send("CORS forbidden") : e();
|
|
4419
|
-
}),
|
|
4510
|
+
}), t.use(ne.json()), t;
|
|
4420
4511
|
}
|
|
4421
|
-
function Co(
|
|
4422
|
-
const
|
|
4423
|
-
return
|
|
4512
|
+
function Co(r) {
|
|
4513
|
+
const t = ne.Router();
|
|
4514
|
+
return t.use(pr({ authToken: r.authToken })), t.all("/mcp", yr(r)), t;
|
|
4424
4515
|
}
|
|
4425
|
-
function
|
|
4426
|
-
return
|
|
4516
|
+
function Eo(r, t) {
|
|
4517
|
+
return r.use(xo({ logFilePath: t.logFilePath })), new Promise((s, o) => {
|
|
4427
4518
|
let e;
|
|
4428
4519
|
const n = () => {
|
|
4429
4520
|
s(e);
|
|
4430
4521
|
};
|
|
4431
4522
|
try {
|
|
4432
|
-
e =
|
|
4523
|
+
e = t.host ? r.listen(t.port ?? 0, t.host, n) : r.listen(t.port ?? 0, n), e.addListener("error", (i) => {
|
|
4433
4524
|
o(i);
|
|
4434
4525
|
});
|
|
4435
4526
|
} catch (i) {
|
|
@@ -4437,40 +4528,40 @@ function vo(t, r) {
|
|
|
4437
4528
|
}
|
|
4438
4529
|
});
|
|
4439
4530
|
}
|
|
4440
|
-
function
|
|
4441
|
-
if (!
|
|
4531
|
+
function No(r, t) {
|
|
4532
|
+
if (!r.address())
|
|
4442
4533
|
throw new Error(
|
|
4443
4534
|
"Server address is not available. Check your DNS and host configuration."
|
|
4444
4535
|
);
|
|
4445
|
-
const o =
|
|
4446
|
-
let n =
|
|
4536
|
+
const o = r.address().family, e = r.address().port;
|
|
4537
|
+
let n = r.address().address;
|
|
4447
4538
|
n === "::" ? n = "localhost" : o === "IPv6" && (n = `[${n}]`);
|
|
4448
4539
|
const i = `http://${o === "IPv6" ? `[${n}]` : n}:${e}`;
|
|
4449
4540
|
return `Project Tools - MCP Server Started
|
|
4450
4541
|
|
|
4451
|
-
Server Name: ${
|
|
4452
|
-
Server Version: ${
|
|
4542
|
+
Server Name: ${t.name}
|
|
4543
|
+
Server Version: ${t.version}
|
|
4453
4544
|
Server URL: ${i}/mcp
|
|
4454
4545
|
SSE Endpoint: ${i}/sse
|
|
4455
4546
|
|
|
4456
|
-
Log File: ${k.resolve(
|
|
4547
|
+
Log File: ${k.resolve(t.logFilePath)}`;
|
|
4457
4548
|
}
|
|
4458
|
-
function
|
|
4459
|
-
const s = k.join(
|
|
4549
|
+
function ko(r, t) {
|
|
4550
|
+
const s = k.join(t.logDir, Vt()), o = Jr(r, {
|
|
4460
4551
|
logFilePath: s
|
|
4461
4552
|
});
|
|
4462
|
-
|
|
4553
|
+
t.tools.processManager && Gr(
|
|
4463
4554
|
o,
|
|
4464
|
-
|
|
4465
|
-
),
|
|
4555
|
+
t.tools.processManager
|
|
4556
|
+
), t.tools.fsManager && Ws(o, t.tools.fsManager), t.tools.playwrightManager && So(
|
|
4466
4557
|
o,
|
|
4467
|
-
|
|
4558
|
+
t.tools.playwrightManager
|
|
4468
4559
|
), Pr(o);
|
|
4469
4560
|
}
|
|
4470
|
-
async function
|
|
4471
|
-
const
|
|
4472
|
-
authToken:
|
|
4473
|
-
logFilePath:
|
|
4561
|
+
async function Vo(r) {
|
|
4562
|
+
const t = k.join(r.logDir, Vt()), s = To(), o = Co({
|
|
4563
|
+
authToken: r.authToken,
|
|
4564
|
+
logFilePath: t,
|
|
4474
4565
|
createMcpServer: async (n) => {
|
|
4475
4566
|
const i = n.headers["x-project-name"];
|
|
4476
4567
|
if (!i)
|
|
@@ -4484,42 +4575,42 @@ X-Project-Name header is missing. To configure MCP for this project:
|
|
|
4484
4575
|
4. Create .mcp.json in project root with X-Project-Name header set to project name
|
|
4485
4576
|
5. Ask user to add project to server's projects config if not already present
|
|
4486
4577
|
6. Ask user to restart Claude Code`);
|
|
4487
|
-
const a =
|
|
4578
|
+
const a = r.projects[i];
|
|
4488
4579
|
if (!a)
|
|
4489
4580
|
throw new Error(`MCP Error: Project "${i}" not found in server configuration.
|
|
4490
4581
|
|
|
4491
4582
|
Ask user to:
|
|
4492
4583
|
1. Add project to server's projects config: projects: { "${i}": "<project-path>" }
|
|
4493
4584
|
2. Restart MCP server`);
|
|
4494
|
-
const c = await
|
|
4495
|
-
title:
|
|
4496
|
-
name:
|
|
4497
|
-
version:
|
|
4585
|
+
const c = await Mo(a), l = new Zt({
|
|
4586
|
+
title: r.title,
|
|
4587
|
+
name: r.name,
|
|
4588
|
+
version: r.version
|
|
4498
4589
|
});
|
|
4499
|
-
return
|
|
4590
|
+
return ko(l, c), l;
|
|
4500
4591
|
}
|
|
4501
4592
|
});
|
|
4502
4593
|
s.use(o);
|
|
4503
|
-
const e = await
|
|
4504
|
-
host:
|
|
4505
|
-
port:
|
|
4506
|
-
logFilePath:
|
|
4594
|
+
const e = await Eo(s, {
|
|
4595
|
+
host: r.host,
|
|
4596
|
+
port: r.port,
|
|
4597
|
+
logFilePath: t
|
|
4507
4598
|
});
|
|
4508
4599
|
return console.log(
|
|
4509
|
-
|
|
4510
|
-
title:
|
|
4511
|
-
name:
|
|
4512
|
-
version:
|
|
4513
|
-
logFilePath:
|
|
4600
|
+
No(e, {
|
|
4601
|
+
title: r.title,
|
|
4602
|
+
name: r.name,
|
|
4603
|
+
version: r.version,
|
|
4604
|
+
logFilePath: t
|
|
4514
4605
|
})
|
|
4515
4606
|
), e;
|
|
4516
4607
|
}
|
|
4517
4608
|
export {
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4609
|
+
Yo as A,
|
|
4610
|
+
Qo as S,
|
|
4611
|
+
Ho as a,
|
|
4612
|
+
Ko as b,
|
|
4613
|
+
Io as l,
|
|
4614
|
+
os as p,
|
|
4615
|
+
Vo as s
|
|
4525
4616
|
};
|