@flemist/mcp-project-tools 3.0.20 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cli.js +25 -87
- package/build/index.d.ts +19 -5
- package/build/index.js +1 -1
- package/build/{startMcpServer-cVbuoauk.js → startMcpServer-CFc7yLZJ.js} +949 -812
- package/flemist-mcp.config.schema.json +290 -0
- package/package.json +4 -1
|
@@ -1,47 +1,50 @@
|
|
|
1
1
|
import ne from "express";
|
|
2
|
-
import { McpServer as
|
|
3
|
-
import { randomUUID as
|
|
4
|
-
import * as
|
|
5
|
-
import * as
|
|
6
|
-
import { StreamableHTTPServerTransport as
|
|
7
|
-
import { spawn as
|
|
2
|
+
import { McpServer as Kt } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { randomUUID as Wt } from "crypto";
|
|
4
|
+
import * as j from "fs";
|
|
5
|
+
import * as k from "path";
|
|
6
|
+
import { StreamableHTTPServerTransport as Ht } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
7
|
+
import { spawn as Qt } from "child_process";
|
|
8
8
|
import { z as h } from "zod";
|
|
9
9
|
import he from "tree-kill";
|
|
10
|
-
import { Pool as
|
|
10
|
+
import { Pool as Yt, poolRunWait as V } from "@flemist/time-limits";
|
|
11
11
|
import { priorityCreate as X } from "@flemist/priority-queue";
|
|
12
|
-
import { useAbortController as
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import { webkit as
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
import { useAbortController as Vt, combineAbortSignals as Zt, Locker as Xt } from "@flemist/async-utils";
|
|
13
|
+
import er from "node:os";
|
|
14
|
+
import tr from "picomatch";
|
|
15
|
+
import { webkit as rr, firefox as sr, chromium as or } from "playwright";
|
|
16
|
+
import nr from "deepmerge";
|
|
17
|
+
import Ee from "json5";
|
|
18
|
+
import ir from "js-yaml";
|
|
19
|
+
function ar(r) {
|
|
20
|
+
const { authToken: t } = r;
|
|
18
21
|
return function(o, e, n) {
|
|
19
|
-
if ((o.query.token || o.headers.authorization?.replace("Bearer ", "")) !==
|
|
22
|
+
if ((o.query.token || o.headers.authorization?.replace("Bearer ", "")) !== t) {
|
|
20
23
|
e.status(401).json({ error: "Unauthorized" });
|
|
21
24
|
return;
|
|
22
25
|
}
|
|
23
26
|
n();
|
|
24
27
|
};
|
|
25
28
|
}
|
|
26
|
-
async function ie(
|
|
27
|
-
const { logFilePath:
|
|
29
|
+
async function ie(r) {
|
|
30
|
+
const { logFilePath: t, message: s, data: o } = r;
|
|
28
31
|
try {
|
|
29
32
|
const e = (/* @__PURE__ */ new Date()).toISOString().replace(/[TZ]/g, " ").trim(), n = typeof o == "string" ? o : JSON.stringify(o, null, 2), i = `[${e}] ${s}
|
|
30
33
|
${n}
|
|
31
34
|
|
|
32
35
|
`;
|
|
33
|
-
await
|
|
36
|
+
await j.promises.mkdir(k.dirname(t), { recursive: !0 }), await j.promises.appendFile(t, i);
|
|
34
37
|
} catch (e) {
|
|
35
38
|
console.error(`Failed to log "${s}":`, e);
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
41
|
const ae = /* @__PURE__ */ new Map();
|
|
39
|
-
function
|
|
40
|
-
return
|
|
42
|
+
function lr(r) {
|
|
43
|
+
return r.headers["mcp-session-id"] || r.headers["x-session-id"] || r.query.token;
|
|
41
44
|
}
|
|
42
|
-
async function
|
|
43
|
-
const s = t.createMcpServer(), o = new
|
|
44
|
-
sessionIdGenerator:
|
|
45
|
+
async function cr(r, t) {
|
|
46
|
+
const s = await t.createMcpServer(r), o = new Ht({
|
|
47
|
+
sessionIdGenerator: Wt,
|
|
45
48
|
onsessioninitialized: (n) => {
|
|
46
49
|
ae.set(n, o);
|
|
47
50
|
},
|
|
@@ -63,28 +66,28 @@ async function nr(t, r) {
|
|
|
63
66
|
throw await e(), n;
|
|
64
67
|
}
|
|
65
68
|
}
|
|
66
|
-
async function
|
|
69
|
+
async function ur(r, t, s, o) {
|
|
67
70
|
await ie({
|
|
68
71
|
logFilePath: s.logFilePath,
|
|
69
72
|
message: "REQUEST",
|
|
70
|
-
data:
|
|
73
|
+
data: r.body
|
|
71
74
|
});
|
|
72
75
|
let e = o ? ae.get(o) : null;
|
|
73
|
-
e || (e = await
|
|
76
|
+
e || (e = await cr(r, s)), await e.handleRequest(r, t, r.body);
|
|
74
77
|
}
|
|
75
|
-
async function
|
|
78
|
+
async function dr(r, t, s) {
|
|
76
79
|
const o = s ? ae.get(s) : null;
|
|
77
80
|
if (!o) {
|
|
78
|
-
|
|
81
|
+
t.status(400).json({ error: "No valid session found" });
|
|
79
82
|
return;
|
|
80
83
|
}
|
|
81
|
-
await o.handleRequest(
|
|
84
|
+
await o.handleRequest(r, t);
|
|
82
85
|
}
|
|
83
|
-
function
|
|
86
|
+
function fr(r) {
|
|
84
87
|
return async function(s, o) {
|
|
85
88
|
try {
|
|
86
|
-
const e =
|
|
87
|
-
s.method === "POST" ? await
|
|
89
|
+
const e = lr(s);
|
|
90
|
+
s.method === "POST" ? await ur(s, o, r, e) : s.method === "GET" ? await dr(s, o, e) : o.status(405).json({ error: "Method not allowed" });
|
|
88
91
|
} catch (e) {
|
|
89
92
|
console.error("Unhandled error in streamableHttpHandler", e), o.status(500).json({
|
|
90
93
|
error: "Internal server error: " + (e instanceof Error ? e.message : "Unknown error")
|
|
@@ -93,13 +96,13 @@ function lr(t) {
|
|
|
93
96
|
};
|
|
94
97
|
}
|
|
95
98
|
const Y = /* @__PURE__ */ new Map();
|
|
96
|
-
let
|
|
97
|
-
const
|
|
98
|
-
function
|
|
99
|
-
const { commandLine:
|
|
99
|
+
let pr = 0;
|
|
100
|
+
const Ne = 10, hr = 1800 * 1e3, J = 1e4, Q = 2e3, mr = 5e3;
|
|
101
|
+
function gr(r) {
|
|
102
|
+
const { commandLine: t, commandLineRules: s } = r;
|
|
100
103
|
let o = !1;
|
|
101
104
|
for (const e of s)
|
|
102
|
-
if (new RegExp(e.regexp).test(
|
|
105
|
+
if (new RegExp(e.regexp).test(t))
|
|
103
106
|
switch (e.rule) {
|
|
104
107
|
case "allow":
|
|
105
108
|
o = !0;
|
|
@@ -112,65 +115,65 @@ function fr(t) {
|
|
|
112
115
|
}
|
|
113
116
|
return o;
|
|
114
117
|
}
|
|
115
|
-
function
|
|
116
|
-
return ++
|
|
118
|
+
function wr() {
|
|
119
|
+
return ++pr;
|
|
117
120
|
}
|
|
118
|
-
let
|
|
119
|
-
function
|
|
120
|
-
if (
|
|
121
|
+
let ke = !1;
|
|
122
|
+
function yr() {
|
|
123
|
+
if (ke)
|
|
121
124
|
return;
|
|
122
|
-
|
|
123
|
-
const
|
|
125
|
+
ke = !0;
|
|
126
|
+
const r = () => {
|
|
124
127
|
console.log("Auto-killing all child processes...");
|
|
125
|
-
for (const [
|
|
128
|
+
for (const [t, s] of Array.from(Y.entries()))
|
|
126
129
|
if (s.isRunning && s.pid)
|
|
127
130
|
try {
|
|
128
131
|
he(s.pid, "SIGKILL");
|
|
129
132
|
} catch (o) {
|
|
130
|
-
console.error(`Error killing process ${
|
|
133
|
+
console.error(`Error killing process ${t}:`, o);
|
|
131
134
|
}
|
|
132
135
|
process.exit(0);
|
|
133
136
|
};
|
|
134
|
-
process.on("SIGINT",
|
|
137
|
+
process.on("SIGINT", r), process.on("SIGTERM", r);
|
|
135
138
|
}
|
|
136
139
|
function ge() {
|
|
137
|
-
const
|
|
140
|
+
const r = Date.now(), t = [];
|
|
138
141
|
for (const [s, o] of Array.from(Y.entries()))
|
|
139
|
-
!o.isRunning && o.endTime &&
|
|
140
|
-
for (const s of
|
|
142
|
+
!o.isRunning && o.endTime && r - o.endTime.getTime() > hr && t.push(s);
|
|
143
|
+
for (const s of t)
|
|
141
144
|
Y.delete(s);
|
|
142
145
|
}
|
|
143
|
-
const
|
|
144
|
-
let
|
|
145
|
-
function
|
|
146
|
-
return ++
|
|
146
|
+
const br = 1800 * 1e3, Oe = /* @__PURE__ */ new Map();
|
|
147
|
+
let Sr = 0;
|
|
148
|
+
function xr() {
|
|
149
|
+
return ++Sr;
|
|
147
150
|
}
|
|
148
|
-
function
|
|
149
|
-
let
|
|
150
|
-
return
|
|
151
|
+
function st(r) {
|
|
152
|
+
let t = Oe.get(r);
|
|
153
|
+
return t == null && (t = {
|
|
151
154
|
storedOutputs: /* @__PURE__ */ new Map()
|
|
152
|
-
},
|
|
155
|
+
}, Oe.set(r, t)), t;
|
|
153
156
|
}
|
|
154
|
-
function
|
|
155
|
-
return typeof
|
|
157
|
+
function ot(r) {
|
|
158
|
+
return typeof r == "function" ? r() : r;
|
|
156
159
|
}
|
|
157
|
-
function
|
|
160
|
+
function nt(r, t) {
|
|
158
161
|
return setTimeout(() => {
|
|
159
|
-
|
|
160
|
-
},
|
|
162
|
+
r.storedOutputs.delete(t);
|
|
163
|
+
}, br);
|
|
161
164
|
}
|
|
162
|
-
function
|
|
163
|
-
clearTimeout(s.cleanupTimer), s.cleanupTimer =
|
|
165
|
+
function $r(r, t, s) {
|
|
166
|
+
clearTimeout(s.cleanupTimer), s.cleanupTimer = nt(r, t);
|
|
164
167
|
}
|
|
165
|
-
function
|
|
166
|
-
const { sessionId:
|
|
168
|
+
function Ir(r) {
|
|
169
|
+
const { sessionId: t, source: s } = r, o = st(t), e = xr(), n = {
|
|
167
170
|
source: s,
|
|
168
|
-
cleanupTimer:
|
|
171
|
+
cleanupTimer: nt(o, e)
|
|
169
172
|
};
|
|
170
173
|
return o.storedOutputs.set(e, n), e;
|
|
171
174
|
}
|
|
172
|
-
function
|
|
173
|
-
const { sessionId:
|
|
175
|
+
function it(r) {
|
|
176
|
+
const { sessionId: t, outputId: s, range: o } = r, [e, n] = o, i = st(t), a = i.storedOutputs.get(s);
|
|
174
177
|
if (a == null)
|
|
175
178
|
return {
|
|
176
179
|
content: "",
|
|
@@ -178,16 +181,16 @@ function ot(t) {
|
|
|
178
181
|
range: [0, 0],
|
|
179
182
|
error: `Stored output with outputId=${s} not found or expired`
|
|
180
183
|
};
|
|
181
|
-
|
|
182
|
-
const c =
|
|
184
|
+
$r(i, s, a);
|
|
185
|
+
const c = ot(a.source), l = c.length, u = Math.min(Math.max(e, 0), l), f = Math.min(Math.max(n, 0), l);
|
|
183
186
|
return { content: c.substring(u, f), total: l, range: [u, f] };
|
|
184
187
|
}
|
|
185
|
-
function we(
|
|
186
|
-
const { sessionId:
|
|
188
|
+
function we(r) {
|
|
189
|
+
const { sessionId: t, source: s, limit: o } = r, e = ot(s);
|
|
187
190
|
if (e.length <= o)
|
|
188
191
|
return { content: e, outputId: null };
|
|
189
|
-
const n =
|
|
190
|
-
sessionId:
|
|
192
|
+
const n = Ir({ sessionId: t, source: s }), i = it({
|
|
193
|
+
sessionId: t,
|
|
191
194
|
outputId: n,
|
|
192
195
|
range: [0, o]
|
|
193
196
|
}), a = `
|
|
@@ -197,27 +200,27 @@ function we(t) {
|
|
|
197
200
|
outputId: n
|
|
198
201
|
};
|
|
199
202
|
}
|
|
200
|
-
function F(
|
|
201
|
-
return `Invalid arguments: ${
|
|
203
|
+
function F(r) {
|
|
204
|
+
return `Invalid arguments: ${r instanceof Error ? r.message : "Unknown error"}.
|
|
202
205
|
|
|
203
206
|
Provide valid parameters according to schema.`;
|
|
204
207
|
}
|
|
205
|
-
const
|
|
208
|
+
const at = h.object({
|
|
206
209
|
outputId: h.number().int().describe("Output ID from truncation message"),
|
|
207
210
|
range: h.tuple([h.number().int().min(0), h.number().int().min(0)]).describe(
|
|
208
|
-
`Character range [from, to) to retrieve. Maximum range size: ${
|
|
211
|
+
`Character range [from, to) to retrieve. Maximum range size: ${J}.`
|
|
209
212
|
)
|
|
210
213
|
});
|
|
211
|
-
function
|
|
214
|
+
function Mr(r, t) {
|
|
212
215
|
let s;
|
|
213
216
|
try {
|
|
214
|
-
s =
|
|
217
|
+
s = at.parse(r);
|
|
215
218
|
} catch (i) {
|
|
216
219
|
return {
|
|
217
220
|
error: F(i)
|
|
218
221
|
};
|
|
219
222
|
}
|
|
220
|
-
if (!
|
|
223
|
+
if (!t.sessionId)
|
|
221
224
|
return {
|
|
222
225
|
error: "Session ID is required"
|
|
223
226
|
};
|
|
@@ -226,32 +229,32 @@ function Sr(t, r) {
|
|
|
226
229
|
return {
|
|
227
230
|
error: `Invalid range: to (${e}) must be greater than from (${o})`
|
|
228
231
|
};
|
|
229
|
-
if (e - o >
|
|
232
|
+
if (e - o > J)
|
|
230
233
|
return {
|
|
231
|
-
error: `Range size ${e - o} exceeds maximum ${
|
|
234
|
+
error: `Range size ${e - o} exceeds maximum ${J}`
|
|
232
235
|
};
|
|
233
|
-
const n =
|
|
234
|
-
sessionId:
|
|
236
|
+
const n = it({
|
|
237
|
+
sessionId: t.sessionId,
|
|
235
238
|
outputId: s.outputId,
|
|
236
239
|
range: s.range
|
|
237
240
|
});
|
|
238
241
|
return n.error != null ? { error: n.error } : { content: n.content, total: n.total, range: n.range };
|
|
239
242
|
}
|
|
240
|
-
function
|
|
241
|
-
|
|
243
|
+
function Tr(r) {
|
|
244
|
+
r(
|
|
242
245
|
"output-read",
|
|
243
246
|
{
|
|
244
247
|
title: "Read Stored Output Range",
|
|
245
248
|
description: "Read any range from stored output. Use outputId from truncation message and specify character range [from, to).",
|
|
246
|
-
inputSchema:
|
|
249
|
+
inputSchema: at.shape
|
|
247
250
|
},
|
|
248
|
-
async (
|
|
249
|
-
const o =
|
|
251
|
+
async (t, s) => {
|
|
252
|
+
const o = Mr(t, s);
|
|
250
253
|
if (o.error != null)
|
|
251
|
-
return `Method: output-read(${JSON.stringify(
|
|
254
|
+
return `Method: output-read(${JSON.stringify(t)})
|
|
252
255
|
❌ Error: ${o.error}`;
|
|
253
256
|
const [e, n] = o.range, i = o.total;
|
|
254
|
-
let a = `Method: output-read(${JSON.stringify(
|
|
257
|
+
let a = `Method: output-read(${JSON.stringify(t)})
|
|
255
258
|
showing [${e}, ${n}) of ${i} chars`;
|
|
256
259
|
return e >= i && (a += `
|
|
257
260
|
⚠️ Warning: requested range is beyond content (total: ${i} chars)`), a += `
|
|
@@ -260,22 +263,22 @@ ${o.content}`, a;
|
|
|
260
263
|
}
|
|
261
264
|
);
|
|
262
265
|
}
|
|
263
|
-
function
|
|
264
|
-
|
|
266
|
+
function Cr(r) {
|
|
267
|
+
Tr(r);
|
|
265
268
|
}
|
|
266
|
-
const
|
|
269
|
+
const lt = h.object({
|
|
267
270
|
id: h.number().describe(
|
|
268
271
|
"Process ID to get detailed status information for. Get process IDs using process-list. Works for both running and completed processes. Examples: 1, 42, 123"
|
|
269
272
|
),
|
|
270
|
-
outputLimit: h.number().int().min(0).max(
|
|
271
|
-
`Maximum output characters to return. Truncated output can be retrieved via output-read tool using outputId from truncation message. Maximum: ${
|
|
273
|
+
outputLimit: h.number().int().min(0).max(J).default(Q).describe(
|
|
274
|
+
`Maximum output characters to return. Truncated output can be retrieved via output-read tool using outputId from truncation message. Maximum: ${J}. Default: ${Q}`
|
|
272
275
|
)
|
|
273
276
|
});
|
|
274
|
-
async function ye(
|
|
277
|
+
async function ye(r, t, s) {
|
|
275
278
|
ge();
|
|
276
279
|
let o;
|
|
277
280
|
try {
|
|
278
|
-
o =
|
|
281
|
+
o = lt.parse(r);
|
|
279
282
|
} catch (c) {
|
|
280
283
|
return {
|
|
281
284
|
error: F(c)
|
|
@@ -297,7 +300,7 @@ async function ye(t, r, s) {
|
|
|
297
300
|
}).content;
|
|
298
301
|
return {
|
|
299
302
|
id: i.id,
|
|
300
|
-
cwd:
|
|
303
|
+
cwd: k.relative(t.workingDir || "", i.cwd),
|
|
301
304
|
commandLine: i.commandLine,
|
|
302
305
|
pid: i.pid,
|
|
303
306
|
startTime: i.startTime.toISOString().replace(/[TZ]/g, " ").trim(),
|
|
@@ -308,16 +311,16 @@ async function ye(t, r, s) {
|
|
|
308
311
|
error: i.error
|
|
309
312
|
};
|
|
310
313
|
}
|
|
311
|
-
function
|
|
312
|
-
|
|
314
|
+
function vr(r, t) {
|
|
315
|
+
r(
|
|
313
316
|
"process-status",
|
|
314
317
|
{
|
|
315
318
|
title: "Get Host Machine Process Status",
|
|
316
319
|
description: "Get detailed status information about a process on the host machine. Use this to check if commands completed successfully, get their output, or monitor running processes",
|
|
317
|
-
inputSchema:
|
|
320
|
+
inputSchema: lt.shape
|
|
318
321
|
},
|
|
319
322
|
async (s, o) => {
|
|
320
|
-
const e = await ye(s,
|
|
323
|
+
const e = await ye(s, t, o);
|
|
321
324
|
if (!("output" in e))
|
|
322
325
|
return `Method: process-status(${JSON.stringify(s)})
|
|
323
326
|
❌ Error: ${e.error}`;
|
|
@@ -330,16 +333,16 @@ ${n.trim()}`;
|
|
|
330
333
|
}
|
|
331
334
|
);
|
|
332
335
|
}
|
|
333
|
-
function
|
|
334
|
-
he(
|
|
335
|
-
|
|
336
|
+
function ct(r) {
|
|
337
|
+
he(r, "SIGTERM", (t) => {
|
|
338
|
+
t && !t.message.includes("not found") && console.error(`Error sending SIGTERM to process ${r}:`, t);
|
|
336
339
|
}), setTimeout(() => {
|
|
337
|
-
he(
|
|
338
|
-
|
|
340
|
+
he(r, "SIGKILL", (t) => {
|
|
341
|
+
t && !t.message.includes("not found") && console.error(`Error sending SIGKILL to process ${r}:`, t);
|
|
339
342
|
});
|
|
340
|
-
},
|
|
343
|
+
}, mr);
|
|
341
344
|
}
|
|
342
|
-
const
|
|
345
|
+
const ut = h.object({
|
|
343
346
|
id: h.number().describe(
|
|
344
347
|
"Process ID to wait for completion. Get process IDs using process-list. The process can be running or already completed. Examples: 1, 42, 123"
|
|
345
348
|
),
|
|
@@ -349,14 +352,14 @@ const lt = h.object({
|
|
|
349
352
|
autoKill: h.boolean().default(!1).describe(
|
|
350
353
|
"Automatically terminate the process if waitTime expires and it is still running. Only applies when waitTime is specified. Default: false (let process continue running after timeout). Set to true for processes that should not run indefinitely"
|
|
351
354
|
),
|
|
352
|
-
outputLimit: h.number().int().min(0).max(
|
|
353
|
-
`Maximum output characters to return. Truncated output can be retrieved via output-read tool using outputId from truncation message. Maximum: ${
|
|
355
|
+
outputLimit: h.number().int().min(0).max(J).default(Q).describe(
|
|
356
|
+
`Maximum output characters to return. Truncated output can be retrieved via output-read tool using outputId from truncation message. Maximum: ${J}. Default: ${Q}`
|
|
354
357
|
)
|
|
355
358
|
});
|
|
356
|
-
async function
|
|
359
|
+
async function dt(r, t, s) {
|
|
357
360
|
let o;
|
|
358
361
|
try {
|
|
359
|
-
o =
|
|
362
|
+
o = ut.parse(r);
|
|
360
363
|
} catch (g) {
|
|
361
364
|
return {
|
|
362
365
|
error: F(g)
|
|
@@ -371,27 +374,27 @@ async function ct(t, r, s) {
|
|
|
371
374
|
let u = !1, f = !1;
|
|
372
375
|
n != null && await new Promise((m) => {
|
|
373
376
|
const y = setInterval(() => {
|
|
374
|
-
c.isRunning ? Date.now() - l >= n * 1e3 && (clearInterval(y), u = !0, i && c.pid && (
|
|
377
|
+
c.isRunning ? Date.now() - l >= n * 1e3 && (clearInterval(y), u = !0, i && c.pid && (ct(c.pid), f = !0), m()) : (clearInterval(y), m());
|
|
375
378
|
}, 100);
|
|
376
379
|
});
|
|
377
380
|
const d = (Date.now() - l) / 1e3;
|
|
378
381
|
return {
|
|
379
|
-
...await ye({ id: e, outputLimit: a },
|
|
382
|
+
...await ye({ id: e, outputLimit: a }, t, s),
|
|
380
383
|
waitDuration: d,
|
|
381
384
|
waitTimeExceeded: u,
|
|
382
385
|
autoKillExecuted: f
|
|
383
386
|
};
|
|
384
387
|
}
|
|
385
|
-
function
|
|
386
|
-
|
|
388
|
+
function Er(r, t) {
|
|
389
|
+
r(
|
|
387
390
|
"process-wait",
|
|
388
391
|
{
|
|
389
392
|
title: "Wait for Host Machine Process",
|
|
390
393
|
description: "Wait for a host machine process to complete execution, with optional timeout and auto-kill functionality. Use this for long-running commands like builds, installs, or tests when you need final results",
|
|
391
|
-
inputSchema:
|
|
394
|
+
inputSchema: ut.shape
|
|
392
395
|
},
|
|
393
396
|
async (s, o) => {
|
|
394
|
-
const e = await
|
|
397
|
+
const e = await dt(s, t, o);
|
|
395
398
|
if (!("output" in e))
|
|
396
399
|
return `Method: process-wait(${JSON.stringify(s)})
|
|
397
400
|
❌ Error: ${e.error}`;
|
|
@@ -404,9 +407,9 @@ ${n.trim()}`;
|
|
|
404
407
|
}
|
|
405
408
|
);
|
|
406
409
|
}
|
|
407
|
-
const
|
|
408
|
-
|
|
409
|
-
'
|
|
410
|
+
const ft = h.object({
|
|
411
|
+
relativeRootDir: h.string().optional().describe(
|
|
412
|
+
'Relative path from project root to working directory for command execution. Use forward slashes. Leave empty for project root. Examples: "src", "src/tools", "tests/unit". Directory must exist'
|
|
410
413
|
),
|
|
411
414
|
commandLine: h.string().describe(
|
|
412
415
|
'Complete command line to execute on the host machine. Include all arguments and options. Examples: "npm install", "pnpm build", "node script.js --verbose", "git status". Command must be in the allowed commands list for security'
|
|
@@ -417,22 +420,22 @@ const ut = h.object({
|
|
|
417
420
|
autoKill: h.boolean().default(!1).describe(
|
|
418
421
|
"Automatically kill the process if waitTime expires and it is still running. Only applies when waitTime is specified. Default: false (let process continue running). Set to true for commands that should not run indefinitely"
|
|
419
422
|
),
|
|
420
|
-
outputLimit: h.number().int().min(0).max(
|
|
421
|
-
`Maximum output characters to return. Truncated output can be retrieved via output-read tool using outputId from truncation message. Maximum: ${
|
|
423
|
+
outputLimit: h.number().int().min(0).max(J).default(Q).describe(
|
|
424
|
+
`Maximum output characters to return. Truncated output can be retrieved via output-read tool using outputId from truncation message. Maximum: ${J}. Default: ${Q}`
|
|
422
425
|
)
|
|
423
426
|
});
|
|
424
|
-
async function
|
|
427
|
+
async function Nr(r, t, s) {
|
|
425
428
|
ge();
|
|
426
429
|
let o;
|
|
427
430
|
try {
|
|
428
|
-
o =
|
|
431
|
+
o = ft.parse(r);
|
|
429
432
|
} catch (p) {
|
|
430
433
|
return {
|
|
431
434
|
error: F(p)
|
|
432
435
|
};
|
|
433
436
|
}
|
|
434
|
-
const { commandLine: e, waitTime: n, autoKill: i, outputLimit: a } = o, { commandLineRules: c } =
|
|
435
|
-
if (!
|
|
437
|
+
const { commandLine: e, waitTime: n, autoKill: i, outputLimit: a } = o, { commandLineRules: c } = t, l = k.resolve(t.workingDir || "", o.relativeRootDir || "");
|
|
438
|
+
if (!gr({ commandLine: e, commandLineRules: c })) {
|
|
436
439
|
const p = c.map(
|
|
437
440
|
(g) => `${g.rule.toUpperCase()}: /${g.regexp}/ (${g.note})`
|
|
438
441
|
).join(`
|
|
@@ -446,11 +449,11 @@ To use this command line, ask the user to modify the command line rules in the c
|
|
|
446
449
|
}
|
|
447
450
|
if (Array.from(Y.values()).filter(
|
|
448
451
|
(p) => p.isRunning
|
|
449
|
-
).length >=
|
|
452
|
+
).length >= Ne)
|
|
450
453
|
return {
|
|
451
|
-
error: `Maximum concurrent process limit reached (${
|
|
454
|
+
error: `Maximum concurrent process limit reached (${Ne} processes). Cannot start new process until existing processes complete. Use process-list to see active processes, or process-kill to terminate unnecessary processes.`
|
|
452
455
|
};
|
|
453
|
-
const f =
|
|
456
|
+
const f = wr(), d = {
|
|
454
457
|
id: f,
|
|
455
458
|
cwd: l,
|
|
456
459
|
commandLine: e,
|
|
@@ -460,7 +463,7 @@ To use this command line, ask the user to modify the command line rules in the c
|
|
|
460
463
|
};
|
|
461
464
|
Y.set(f, d);
|
|
462
465
|
try {
|
|
463
|
-
const p =
|
|
466
|
+
const p = Qt(e, [], {
|
|
464
467
|
shell: !0,
|
|
465
468
|
cwd: l,
|
|
466
469
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -474,28 +477,28 @@ To use this command line, ask the user to modify the command line rules in the c
|
|
|
474
477
|
d.isRunning = !1, d.endTime = /* @__PURE__ */ new Date(), d.exitCode = m !== null ? m : void 0, console.log(`Process ${f} (${e}) exited with code ${m}`);
|
|
475
478
|
}), p.on("error", (m) => {
|
|
476
479
|
d.isRunning = !1, d.endTime = /* @__PURE__ */ new Date(), d.error = m.message, console.error(`Process ${f} error:`, m.message);
|
|
477
|
-
}), n != null ?
|
|
480
|
+
}), n != null ? dt(
|
|
478
481
|
{ id: f, waitTime: n, autoKill: i, outputLimit: a },
|
|
479
|
-
|
|
482
|
+
t,
|
|
480
483
|
s
|
|
481
|
-
) : ye({ id: f, outputLimit: a },
|
|
484
|
+
) : ye({ id: f, outputLimit: a }, t, s);
|
|
482
485
|
} catch (p) {
|
|
483
486
|
return d.isRunning = !1, d.endTime = /* @__PURE__ */ new Date(), d.error = p instanceof Error ? p.message : "Unknown error", { error: d.error };
|
|
484
487
|
}
|
|
485
488
|
}
|
|
486
|
-
function
|
|
487
|
-
const s =
|
|
489
|
+
function kr(r, t) {
|
|
490
|
+
const s = t.commandLineRules.map((o) => `${o.rule.toUpperCase()}: ${o.regexp} (${o.note})`).join(`
|
|
488
491
|
`);
|
|
489
|
-
|
|
492
|
+
r(
|
|
490
493
|
"process-run",
|
|
491
494
|
{
|
|
492
495
|
title: "Execute Command Line on Host Machine",
|
|
493
496
|
description: `Execute command lines on the host machine. Use this to build, test, lint, install packages, or run system commands. Prefer process-run with waitTime parameter if you need to immediately execute and wait for completion, instead of separate process-run and process-wait calls. Security: Command lines are validated against configured rules processed in order (later rules override earlier ones). Current command line rules:
|
|
494
497
|
${s}`,
|
|
495
|
-
inputSchema:
|
|
498
|
+
inputSchema: ft.shape
|
|
496
499
|
},
|
|
497
500
|
async (o, e) => {
|
|
498
|
-
const n = await
|
|
501
|
+
const n = await Nr(o, t, e);
|
|
499
502
|
if (!("output" in n))
|
|
500
503
|
return `Method: process-run(${JSON.stringify(o)})
|
|
501
504
|
❌ Error: ${n.error}`;
|
|
@@ -508,7 +511,7 @@ ${i.trim()}`;
|
|
|
508
511
|
}
|
|
509
512
|
);
|
|
510
513
|
}
|
|
511
|
-
const
|
|
514
|
+
const pt = h.object({
|
|
512
515
|
minOpenDateTime: h.string().optional().describe(
|
|
513
516
|
'Filter to processes started after this datetime. Accepts ISO format or space-separated format. Examples: "2024-01-15T10:30:00Z", "2024-01-15 10:30:00". Underscores and spaces are converted to standard ISO format internally'
|
|
514
517
|
),
|
|
@@ -522,11 +525,11 @@ const dt = h.object({
|
|
|
522
525
|
'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'
|
|
523
526
|
)
|
|
524
527
|
});
|
|
525
|
-
async function
|
|
528
|
+
async function Or(r, t) {
|
|
526
529
|
ge();
|
|
527
530
|
let s;
|
|
528
531
|
try {
|
|
529
|
-
s =
|
|
532
|
+
s = pt.parse(r);
|
|
530
533
|
} catch (l) {
|
|
531
534
|
return {
|
|
532
535
|
error: F(l)
|
|
@@ -545,7 +548,7 @@ async function vr(t, r) {
|
|
|
545
548
|
return n && (a = a.filter((l) => l.isRunning)), { processes: a.map((l) => {
|
|
546
549
|
let u = {
|
|
547
550
|
id: l.id,
|
|
548
|
-
cwd:
|
|
551
|
+
cwd: k.relative(t.workingDir || "", l.cwd),
|
|
549
552
|
commandLine: l.commandLine,
|
|
550
553
|
pid: l.pid,
|
|
551
554
|
startTime: l.startTime.toISOString().replace(/[TZ]/g, " ").trim(),
|
|
@@ -565,16 +568,16 @@ async function vr(t, r) {
|
|
|
565
568
|
return u;
|
|
566
569
|
}) };
|
|
567
570
|
}
|
|
568
|
-
function
|
|
569
|
-
|
|
571
|
+
function Dr(r, t) {
|
|
572
|
+
r(
|
|
570
573
|
"process-list",
|
|
571
574
|
{
|
|
572
575
|
title: "List Host Machine Processes",
|
|
573
576
|
description: "List all processes that have been executed on the host machine. Use this to see running processes, check command history, or find process IDs for status/wait operations",
|
|
574
|
-
inputSchema:
|
|
577
|
+
inputSchema: pt.shape
|
|
575
578
|
},
|
|
576
579
|
async (s) => {
|
|
577
|
-
const o = await
|
|
580
|
+
const o = await Or(s, t);
|
|
578
581
|
if (o.error != null)
|
|
579
582
|
return `Method: process-list(${JSON.stringify(s)})
|
|
580
583
|
❌ Error: ${o.error}`;
|
|
@@ -588,21 +591,21 @@ ${e}`;
|
|
|
588
591
|
}
|
|
589
592
|
);
|
|
590
593
|
}
|
|
591
|
-
const
|
|
594
|
+
const ht = h.object({
|
|
592
595
|
id: h.number().describe(
|
|
593
596
|
"Process ID of the process to terminate. Get process IDs using process-list. The process must be currently running. Examples: 1, 42, 123"
|
|
594
597
|
)
|
|
595
598
|
});
|
|
596
|
-
function
|
|
597
|
-
let
|
|
599
|
+
function Rr(r) {
|
|
600
|
+
let t;
|
|
598
601
|
try {
|
|
599
|
-
|
|
602
|
+
t = ht.parse(r);
|
|
600
603
|
} catch (e) {
|
|
601
604
|
return {
|
|
602
605
|
error: F(e)
|
|
603
606
|
};
|
|
604
607
|
}
|
|
605
|
-
const { id: s } =
|
|
608
|
+
const { id: s } = t, o = Y.get(s);
|
|
606
609
|
if (!o)
|
|
607
610
|
return {
|
|
608
611
|
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.`
|
|
@@ -616,54 +619,54 @@ function Nr(t) {
|
|
|
616
619
|
error: `Process ${s} has no system process ID (PID). This indicates the process failed to start properly or the system was unable to assign a PID. Check process-status for error details.`
|
|
617
620
|
};
|
|
618
621
|
try {
|
|
619
|
-
return
|
|
622
|
+
return ct(o.pid), { success: !0, message: `Kill signal sent to process ${s}` };
|
|
620
623
|
} catch (e) {
|
|
621
624
|
return {
|
|
622
625
|
error: `Failed to terminate process ${s}: ${e instanceof Error ? e.message : "Unknown error"}. The process may have already exited, be protected by the system, or there may be insufficient permissions. Use process-status to check current process state.`
|
|
623
626
|
};
|
|
624
627
|
}
|
|
625
628
|
}
|
|
626
|
-
function
|
|
627
|
-
|
|
629
|
+
function Fr(r, t) {
|
|
630
|
+
r(
|
|
628
631
|
"process-kill",
|
|
629
632
|
{
|
|
630
633
|
title: "Kill Host Machine Process",
|
|
631
634
|
description: "Forcibly terminate a running process on the host machine. Use this to stop runaway processes, hung commands, or long-running tasks that need to be cancelled",
|
|
632
|
-
inputSchema:
|
|
635
|
+
inputSchema: ht.shape
|
|
633
636
|
},
|
|
634
637
|
async (s) => {
|
|
635
|
-
const o =
|
|
638
|
+
const o = Rr(s);
|
|
636
639
|
return o.error != null ? `Method: process-kill(${JSON.stringify(s)})
|
|
637
640
|
❌ Error: ${o.error}` : `Method: process-kill(${JSON.stringify(s)})
|
|
638
641
|
${JSON.stringify(o, null, 2)}`;
|
|
639
642
|
}
|
|
640
643
|
);
|
|
641
644
|
}
|
|
642
|
-
function
|
|
643
|
-
|
|
644
|
-
const s =
|
|
645
|
+
function Br(r, t) {
|
|
646
|
+
yr(), t.run && kr(r, t), t.status && vr(r, t), t.wait && Er(r, t), t.list && Dr(r, t), t.kill && Fr(r);
|
|
647
|
+
const s = t.commandLineRules?.map(
|
|
645
648
|
(o) => `${o.rule.toUpperCase()}: ${o.regexp} (${o.note})`
|
|
646
649
|
) || [];
|
|
647
650
|
console.log(
|
|
648
651
|
`Process manager:
|
|
649
|
-
- Working directory: ${
|
|
650
|
-
- Command line rules: ${
|
|
652
|
+
- Working directory: ${k.resolve(t.workingDir || "")}
|
|
653
|
+
- Command line rules: ${t.commandLineRules?.length || 0} rules configured:
|
|
651
654
|
${s.map((o) => `- ${o}`).join(`
|
|
652
655
|
`)}
|
|
653
656
|
`
|
|
654
657
|
);
|
|
655
658
|
}
|
|
656
|
-
function
|
|
659
|
+
function Lr(r, t) {
|
|
657
660
|
return function(o, e, n) {
|
|
658
661
|
const i = async (...a) => {
|
|
659
662
|
await ie({
|
|
660
|
-
logFilePath:
|
|
663
|
+
logFilePath: t.logFilePath,
|
|
661
664
|
message: "REQUEST",
|
|
662
665
|
data: { name: o, args: a }
|
|
663
666
|
});
|
|
664
667
|
const c = await n(...a);
|
|
665
668
|
return await ie({
|
|
666
|
-
logFilePath:
|
|
669
|
+
logFilePath: t.logFilePath,
|
|
667
670
|
message: "RESPONSE",
|
|
668
671
|
data: c
|
|
669
672
|
}), {
|
|
@@ -675,35 +678,35 @@ function Dr(t, r) {
|
|
|
675
678
|
]
|
|
676
679
|
};
|
|
677
680
|
};
|
|
678
|
-
return
|
|
681
|
+
return r.registerTool(
|
|
679
682
|
o,
|
|
680
683
|
e,
|
|
681
684
|
i
|
|
682
685
|
);
|
|
683
686
|
};
|
|
684
687
|
}
|
|
685
|
-
function
|
|
686
|
-
return
|
|
688
|
+
function Pr(r) {
|
|
689
|
+
return r.match(/^[/\\]?[^/\\]+/)[0];
|
|
687
690
|
}
|
|
688
|
-
function
|
|
689
|
-
return
|
|
691
|
+
function Ar(r, t) {
|
|
692
|
+
return Pr(r) + "|" + t.ino;
|
|
690
693
|
}
|
|
691
|
-
function
|
|
692
|
-
return
|
|
694
|
+
function zr(r) {
|
|
695
|
+
return r.endsWith(":") && (r += "/"), k.resolve(r);
|
|
693
696
|
}
|
|
694
|
-
const be = new
|
|
695
|
-
function
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
),
|
|
697
|
+
const be = new Yt(er.cpus().length);
|
|
698
|
+
function De(r, t) {
|
|
699
|
+
r.totalSize += t.totalSize, r.maxFileDateModified = Math.max(
|
|
700
|
+
r.maxFileDateModified,
|
|
701
|
+
t.maxFileDateModified
|
|
702
|
+
), r.countFiles += t.countFiles, r.countDirs += t.countDirs, r.countLinks += t.countLinks;
|
|
700
703
|
}
|
|
701
|
-
const
|
|
702
|
-
return
|
|
704
|
+
const Ur = function(t) {
|
|
705
|
+
return t.code === "ENOENT";
|
|
703
706
|
};
|
|
704
|
-
function
|
|
705
|
-
const
|
|
706
|
-
if (!
|
|
707
|
+
function mt(r) {
|
|
708
|
+
const t = r.paths;
|
|
709
|
+
if (!t || t.length === 0)
|
|
707
710
|
return Promise.resolve({
|
|
708
711
|
totalSize: 0,
|
|
709
712
|
maxFileDateModified: 0,
|
|
@@ -711,16 +714,16 @@ function pt(t) {
|
|
|
711
714
|
countDirs: 0,
|
|
712
715
|
countLinks: 0
|
|
713
716
|
});
|
|
714
|
-
const s =
|
|
717
|
+
const s = r.level ?? 0, o = r.walkedIds ?? /* @__PURE__ */ new Set(), e = r.abortSignal, n = r.pool ?? be, i = r.handleError, a = r.priority ?? X(0), c = r.walkLinks ?? !1, l = r.log, u = r.handlePath, f = r.matchPath;
|
|
715
718
|
async function d(g) {
|
|
716
|
-
if (!(i && await i(g)) && !
|
|
719
|
+
if (!(i && await i(g)) && !Ur(g))
|
|
717
720
|
throw g;
|
|
718
721
|
}
|
|
719
722
|
function p(g) {
|
|
720
723
|
return !(!l || l.minTotalContentSize != null && g < l.minTotalContentSize || l.maxNestedLevel != null && s > l.maxNestedLevel);
|
|
721
724
|
}
|
|
722
|
-
return
|
|
723
|
-
const m =
|
|
725
|
+
return Vt(async (g) => {
|
|
726
|
+
const m = Zt(e, g), y = {
|
|
724
727
|
totalSize: 0,
|
|
725
728
|
maxFileDateModified: 0,
|
|
726
729
|
countFiles: 0,
|
|
@@ -759,18 +762,18 @@ function pt(t) {
|
|
|
759
762
|
T || (T = $);
|
|
760
763
|
const v = await V({
|
|
761
764
|
pool: n,
|
|
762
|
-
func: () =>
|
|
765
|
+
func: () => j.promises.lstat($).catch(d),
|
|
763
766
|
count: 1,
|
|
764
767
|
priority: X(S, X(1, a)),
|
|
765
768
|
abortSignal: m
|
|
766
769
|
});
|
|
767
770
|
if (!v || !x && v.isFile())
|
|
768
771
|
return null;
|
|
769
|
-
const B =
|
|
772
|
+
const B = Ar($, v);
|
|
770
773
|
if (o.has(B))
|
|
771
774
|
return null;
|
|
772
775
|
o.add(B);
|
|
773
|
-
let
|
|
776
|
+
let O = {
|
|
774
777
|
totalSize: v.size,
|
|
775
778
|
maxFileDateModified: v.isDirectory() ? 0 : v.mtimeMs,
|
|
776
779
|
countFiles: 0,
|
|
@@ -785,40 +788,40 @@ function pt(t) {
|
|
|
785
788
|
if (c) {
|
|
786
789
|
const C = await V({
|
|
787
790
|
pool: n,
|
|
788
|
-
func: () =>
|
|
791
|
+
func: () => j.promises.readlink($).catch(d).then((N) => N ?? null),
|
|
789
792
|
count: 1,
|
|
790
793
|
priority: I,
|
|
791
794
|
abortSignal: m
|
|
792
795
|
});
|
|
793
796
|
if (C) {
|
|
794
|
-
const N =
|
|
797
|
+
const N = k.isAbsolute(C) ? C : k.resolve(k.dirname(T), C), D = await E(
|
|
795
798
|
N,
|
|
796
799
|
S,
|
|
797
800
|
x,
|
|
798
801
|
T
|
|
799
802
|
);
|
|
800
|
-
|
|
803
|
+
D && (O = D);
|
|
801
804
|
}
|
|
802
805
|
}
|
|
803
|
-
return (x ||
|
|
806
|
+
return (x || O.countFiles + O.countDirs + O.countLinks >= 1) && (O.countLinks += 1, await M(
|
|
804
807
|
T,
|
|
805
808
|
v,
|
|
806
|
-
|
|
809
|
+
O,
|
|
807
810
|
I
|
|
808
|
-
) && (
|
|
811
|
+
) && (De(y, O), w(T, O))), O;
|
|
809
812
|
} else if (v.isDirectory()) {
|
|
810
813
|
const C = await V({
|
|
811
814
|
pool: n,
|
|
812
|
-
func: () =>
|
|
815
|
+
func: () => j.promises.readdir($).catch(d),
|
|
813
816
|
count: 1,
|
|
814
817
|
priority: a,
|
|
815
818
|
abortSignal: m
|
|
816
819
|
});
|
|
817
820
|
if (C) {
|
|
818
|
-
for (let N = 0,
|
|
819
|
-
C[N] =
|
|
820
|
-
|
|
821
|
-
...
|
|
821
|
+
for (let N = 0, D = C.length; N < D; N++)
|
|
822
|
+
C[N] = k.join(T, C[N]);
|
|
823
|
+
O = await mt({
|
|
824
|
+
...r,
|
|
822
825
|
paths: C,
|
|
823
826
|
abortSignal: m,
|
|
824
827
|
priority: I,
|
|
@@ -827,78 +830,78 @@ function pt(t) {
|
|
|
827
830
|
});
|
|
828
831
|
}
|
|
829
832
|
}
|
|
830
|
-
return (x ||
|
|
833
|
+
return (x || O.countFiles + O.countDirs + O.countLinks >= 1) && (v.isDirectory() ? O.countDirs += 1 : v.isFile() && (O.countFiles += 1), await M(
|
|
831
834
|
T,
|
|
832
835
|
v,
|
|
833
|
-
|
|
836
|
+
O,
|
|
834
837
|
I
|
|
835
|
-
) && (
|
|
838
|
+
) && (De(y, O), w(T, O))), O;
|
|
836
839
|
}
|
|
837
840
|
const b = [];
|
|
838
|
-
for (let $ = 0, S =
|
|
839
|
-
const x =
|
|
841
|
+
for (let $ = 0, S = t.length; $ < S; $++) {
|
|
842
|
+
const x = zr(t[$]), T = f ? f(x) : !0;
|
|
840
843
|
T !== !1 && b.push(E(x, $, T));
|
|
841
844
|
}
|
|
842
845
|
return await Promise.all(b), y;
|
|
843
846
|
});
|
|
844
847
|
}
|
|
845
|
-
function
|
|
846
|
-
return
|
|
848
|
+
function gt(r) {
|
|
849
|
+
return mt(r);
|
|
847
850
|
}
|
|
848
|
-
function H(
|
|
849
|
-
return
|
|
851
|
+
function H(r) {
|
|
852
|
+
return r.replace(/\\/g, "/");
|
|
850
853
|
}
|
|
851
|
-
function
|
|
852
|
-
if (!
|
|
853
|
-
return
|
|
854
|
-
const s =
|
|
855
|
-
s && (
|
|
856
|
-
const o =
|
|
857
|
-
return o && (
|
|
854
|
+
function jr(r, t) {
|
|
855
|
+
if (!t || t === ".")
|
|
856
|
+
return r;
|
|
857
|
+
const s = r.startsWith("^");
|
|
858
|
+
s && (r = r.substring(1));
|
|
859
|
+
const o = r.startsWith("!");
|
|
860
|
+
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;
|
|
858
861
|
}
|
|
859
|
-
function
|
|
860
|
-
const
|
|
861
|
-
return
|
|
862
|
+
function qr(r) {
|
|
863
|
+
const t = r.startsWith("!");
|
|
864
|
+
return t && (r = r.substring(1)), r.startsWith("/") ? r = r.substring(1) : !r.startsWith("**") && !r.startsWith("../") && (r = `**/${r}`), t && (r = "!" + r), r;
|
|
862
865
|
}
|
|
863
|
-
function
|
|
864
|
-
return "^" +
|
|
866
|
+
function Re(r) {
|
|
867
|
+
return "^" + r;
|
|
865
868
|
}
|
|
866
|
-
async function
|
|
867
|
-
const s = (await
|
|
869
|
+
async function Gr(r) {
|
|
870
|
+
const s = (await j.promises.readFile(r, "utf-8")).split(`
|
|
868
871
|
`), o = [];
|
|
869
872
|
return s.forEach((e) => {
|
|
870
873
|
e = e.trim(), !(!e || e.startsWith("#")) && o.push(e);
|
|
871
874
|
}), o;
|
|
872
875
|
}
|
|
873
|
-
async function
|
|
874
|
-
const
|
|
875
|
-
if (!
|
|
876
|
+
async function wt(r) {
|
|
877
|
+
const t = r.rootDir ?? ".", s = [];
|
|
878
|
+
if (!r.globs?.length)
|
|
876
879
|
return s;
|
|
877
880
|
const o = [];
|
|
878
|
-
return
|
|
879
|
-
e.value && (e.valueType === "file-contains-patterns" ? o.push(e) : e.valueType === "pattern" && s.push(e.exclude ?
|
|
881
|
+
return r.globs.forEach((e) => {
|
|
882
|
+
e.value && (e.valueType === "file-contains-patterns" ? o.push(e) : e.valueType === "pattern" && s.push(e.exclude ? Re(e.value) : e.value));
|
|
880
883
|
}), o.length && await Promise.all(
|
|
881
884
|
o.map(async (e) => {
|
|
882
885
|
await V({
|
|
883
886
|
pool: be,
|
|
884
887
|
count: 1,
|
|
885
888
|
func: async () => {
|
|
886
|
-
const n =
|
|
889
|
+
const n = k.resolve(t, e.value), i = await Gr(n), a = k.relative(t, k.dirname(n));
|
|
887
890
|
i.forEach((c) => {
|
|
888
|
-
c =
|
|
891
|
+
c = qr(c), c = jr(c, a), s.push(e.exclude ? Re(c) : c);
|
|
889
892
|
});
|
|
890
893
|
}
|
|
891
894
|
});
|
|
892
895
|
})
|
|
893
896
|
), s;
|
|
894
897
|
}
|
|
895
|
-
function
|
|
896
|
-
globs:
|
|
897
|
-
rootDir:
|
|
898
|
+
function yt({
|
|
899
|
+
globs: r,
|
|
900
|
+
rootDir: t,
|
|
898
901
|
noCase: s
|
|
899
902
|
}) {
|
|
900
903
|
const o = [];
|
|
901
|
-
return
|
|
904
|
+
return r.forEach((e) => {
|
|
902
905
|
e = H(e).trim();
|
|
903
906
|
const n = e.startsWith("^");
|
|
904
907
|
n && (e = e.substring(1).trim());
|
|
@@ -908,12 +911,12 @@ function gt({
|
|
|
908
911
|
`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.`
|
|
909
912
|
);
|
|
910
913
|
e.startsWith("/") && (e = "." + e);
|
|
911
|
-
const a = H(
|
|
914
|
+
const a = H(t ? k.resolve(t, e) : e);
|
|
912
915
|
if (!a)
|
|
913
916
|
return;
|
|
914
917
|
let c;
|
|
915
918
|
try {
|
|
916
|
-
c =
|
|
919
|
+
c = tr(a, {
|
|
917
920
|
nocase: s ?? !1,
|
|
918
921
|
dot: !0,
|
|
919
922
|
strictBrackets: !0
|
|
@@ -940,61 +943,61 @@ function gt({
|
|
|
940
943
|
return a ? !1 : i;
|
|
941
944
|
};
|
|
942
945
|
}
|
|
943
|
-
async function
|
|
944
|
-
const
|
|
945
|
-
|
|
946
|
-
const e = await
|
|
947
|
-
rootDir:
|
|
948
|
-
globs:
|
|
946
|
+
async function _r(r) {
|
|
947
|
+
const t = r.rootDir ?? ".", s = [], o = {};
|
|
948
|
+
r.result.countFiles && (o.countFiles = 0), r.result.size && (o.size = 0);
|
|
949
|
+
const e = await wt({
|
|
950
|
+
rootDir: t,
|
|
951
|
+
globs: r.globs
|
|
949
952
|
});
|
|
950
|
-
return await
|
|
951
|
-
paths: [
|
|
953
|
+
return await gt({
|
|
954
|
+
paths: [t],
|
|
952
955
|
walkLinks: !0,
|
|
953
|
-
matchPath:
|
|
956
|
+
matchPath: yt({
|
|
954
957
|
globs: e,
|
|
955
|
-
rootDir:
|
|
958
|
+
rootDir: t,
|
|
956
959
|
noCase: !0
|
|
957
960
|
}),
|
|
958
961
|
handlePath: async ({ path: n, stat: i, itemStat: a }) => {
|
|
959
|
-
const c =
|
|
962
|
+
const c = k.relative(t, n), l = i.isDirectory(), u = i.isFile();
|
|
960
963
|
if (!l && !u)
|
|
961
964
|
return !0;
|
|
962
965
|
const f = H(c || "."), d = l ? "dir" : "file", p = l ? a.maxFileDateModified || null : i.mtimeMs, g = l ? a.totalSize : i.size, m = l ? a.countFiles : null, y = {
|
|
963
966
|
path: f,
|
|
964
967
|
type: d
|
|
965
968
|
};
|
|
966
|
-
if (
|
|
967
|
-
const [w, M] =
|
|
969
|
+
if (r.result.dateModified && (y.dateModified = p), r.result.size && (y.size = g), r.result.countFiles && (y.countFiles = m), r.dateModified && p != null) {
|
|
970
|
+
const [w, M] = r.dateModified;
|
|
968
971
|
if (w != null && p < w || M != null && p > M)
|
|
969
972
|
return !1;
|
|
970
973
|
}
|
|
971
|
-
if (
|
|
972
|
-
const [w, M] =
|
|
974
|
+
if (r.totalSize && g != null) {
|
|
975
|
+
const [w, M] = r.totalSize;
|
|
973
976
|
if (w != null && g < w || M != null && g > M)
|
|
974
977
|
return !1;
|
|
975
978
|
}
|
|
976
|
-
return d === "file" && (o.countFiles = (o.countFiles ?? 0) + 1), d === "file" && g != null && (o.size = (o.size ?? 0) + g), p != null && (o.dateModified == null || p > o.dateModified) && (o.dateModified = p), l && !
|
|
979
|
+
return d === "file" && (o.countFiles = (o.countFiles ?? 0) + 1), d === "file" && g != null && (o.size = (o.size ?? 0) + g), p != null && (o.dateModified == null || p > o.dateModified) && (o.dateModified = p), l && !r.result.dirs || u && !r.result.files || s.push(y), !0;
|
|
977
980
|
}
|
|
978
981
|
}), { items: s, totals: o };
|
|
979
982
|
}
|
|
980
|
-
const
|
|
981
|
-
function
|
|
982
|
-
if (
|
|
983
|
-
let
|
|
984
|
-
for (;
|
|
985
|
-
|
|
986
|
-
return `${s === 0 ?
|
|
983
|
+
const Fe = ["B", "KB", "MB", "GB", "TB"], Be = 1024;
|
|
984
|
+
function Le(r) {
|
|
985
|
+
if (r == null) return "-";
|
|
986
|
+
let t = r ?? 0, s = 0;
|
|
987
|
+
for (; t >= Be && s < Fe.length - 1; )
|
|
988
|
+
t /= Be, s++;
|
|
989
|
+
return `${s === 0 ? t.toString() : t.toFixed(2)}${Fe[s]}`;
|
|
987
990
|
}
|
|
988
|
-
function
|
|
989
|
-
const s = Date.now() -
|
|
991
|
+
function Pe(r) {
|
|
992
|
+
const s = Date.now() - r;
|
|
990
993
|
if (s < 0) return "0s";
|
|
991
994
|
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);
|
|
992
995
|
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`;
|
|
993
996
|
}
|
|
994
|
-
function
|
|
995
|
-
return
|
|
996
|
-
for (let e = 0, n =
|
|
997
|
-
const i =
|
|
997
|
+
function Jr(r, t) {
|
|
998
|
+
return t?.length ? [...r].sort((s, o) => {
|
|
999
|
+
for (let e = 0, n = t.length; e < n; e++) {
|
|
1000
|
+
const i = t[e];
|
|
998
1001
|
let a, c;
|
|
999
1002
|
switch (i.field) {
|
|
1000
1003
|
case "type":
|
|
@@ -1025,10 +1028,10 @@ function qr(t, r) {
|
|
|
1025
1028
|
return i.desc ? -l : l;
|
|
1026
1029
|
}
|
|
1027
1030
|
return 0;
|
|
1028
|
-
}) :
|
|
1031
|
+
}) : r;
|
|
1029
1032
|
}
|
|
1030
|
-
function
|
|
1031
|
-
const s =
|
|
1033
|
+
function Kr(r, t) {
|
|
1034
|
+
const s = Jr(r.items, t.sort ?? []), o = t.fields && t.fields.length > 0 ? t.fields : [];
|
|
1032
1035
|
let e = "";
|
|
1033
1036
|
if (s.length > 0 && o.length > 0) {
|
|
1034
1037
|
for (let n = 0, i = o.length; n < i; n++) {
|
|
@@ -1059,10 +1062,10 @@ function Gr(t, r) {
|
|
|
1059
1062
|
const u = o[c];
|
|
1060
1063
|
switch (c > 0 && (e += " | "), u) {
|
|
1061
1064
|
case "dateModified":
|
|
1062
|
-
e += a.dateModified ?
|
|
1065
|
+
e += a.dateModified ? Pe(a.dateModified) : "-";
|
|
1063
1066
|
break;
|
|
1064
1067
|
case "size":
|
|
1065
|
-
e +=
|
|
1068
|
+
e += Le(a.size);
|
|
1066
1069
|
break;
|
|
1067
1070
|
case "type":
|
|
1068
1071
|
e += a.type;
|
|
@@ -1081,24 +1084,24 @@ function Gr(t, r) {
|
|
|
1081
1084
|
e.length > 0 && (e += `
|
|
1082
1085
|
---
|
|
1083
1086
|
`);
|
|
1084
|
-
const n =
|
|
1085
|
-
e += `Totals: ${
|
|
1087
|
+
const n = Le(r.totals.size ?? 0), i = r.totals.dateModified ? `, last modified ${Pe(r.totals.dateModified)} ago` : "";
|
|
1088
|
+
e += `Totals: ${r.totals.countFiles ?? 0} files in dirs, ${n}${i}`;
|
|
1086
1089
|
}
|
|
1087
1090
|
return e;
|
|
1088
1091
|
}
|
|
1089
|
-
const
|
|
1090
|
-
version:
|
|
1091
|
-
},
|
|
1092
|
-
function
|
|
1093
|
-
const
|
|
1092
|
+
const Wr = "4.0.1", Hr = {
|
|
1093
|
+
version: Wr
|
|
1094
|
+
}, Po = "Project Tools", Ao = "project-tools", zo = Hr.version, Uo = "d00f70240703039df14c76176a055bce6b5484d2b552ba2c89820f03b8e5e60d", Ae = 25e3;
|
|
1095
|
+
function ze(r) {
|
|
1096
|
+
const t = r.match(
|
|
1094
1097
|
/^\s*(\d+(?:\.\d+)?)\s*([smhdwMY]|sec(onds?)?|min(utes?)?|hours?|days?|weeks?|months?|years?)\s*$/i
|
|
1095
1098
|
);
|
|
1096
|
-
if (!
|
|
1099
|
+
if (!t)
|
|
1097
1100
|
throw new Error(
|
|
1098
|
-
`Invalid time ago format: "${
|
|
1101
|
+
`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).`
|
|
1099
1102
|
);
|
|
1100
|
-
const s = parseFloat(
|
|
1101
|
-
let o =
|
|
1103
|
+
const s = parseFloat(t[1]);
|
|
1104
|
+
let o = t[2];
|
|
1102
1105
|
switch (o !== "M" && (o = o.toLowerCase(), o.startsWith("month") ? o = "M" : o.length > 1 && (o = o[0])), o) {
|
|
1103
1106
|
case "s":
|
|
1104
1107
|
return s * 1e3;
|
|
@@ -1120,13 +1123,13 @@ function Ae(t) {
|
|
|
1120
1123
|
);
|
|
1121
1124
|
}
|
|
1122
1125
|
}
|
|
1123
|
-
function
|
|
1124
|
-
const
|
|
1125
|
-
if (!
|
|
1126
|
+
function Ue(r) {
|
|
1127
|
+
const t = r.match(/^\s*(\d+(?:\.\d+)?)\s*(B|KB|MB|GB|TB)\s*$/i);
|
|
1128
|
+
if (!t)
|
|
1126
1129
|
throw new Error(
|
|
1127
|
-
`Invalid size format: "${
|
|
1130
|
+
`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.`
|
|
1128
1131
|
);
|
|
1129
|
-
const s = parseFloat(
|
|
1132
|
+
const s = parseFloat(t[1]), o = t[2].toUpperCase();
|
|
1130
1133
|
switch (o) {
|
|
1131
1134
|
case "B":
|
|
1132
1135
|
return s;
|
|
@@ -1144,9 +1147,9 @@ function ze(t) {
|
|
|
1144
1147
|
);
|
|
1145
1148
|
}
|
|
1146
1149
|
}
|
|
1147
|
-
const
|
|
1148
|
-
|
|
1149
|
-
'
|
|
1150
|
+
const bt = h.object({
|
|
1151
|
+
relativeRootDir: h.string().optional().describe(
|
|
1152
|
+
'Relative path from project root to directory for listing. Use forward slashes. Leave empty for project root. Examples: "src", "src/components", "tests". Path must exist'
|
|
1150
1153
|
),
|
|
1151
1154
|
globs: h.array(h.string()).optional().describe(
|
|
1152
1155
|
'Glob patterns to filter which files/directories to include. Add leading ** to match files and dirs in subdirectories. Examples: ["**/*.js"] (JavaScript files), ["src/**/*.ts"] (TypeScript files in src), ["**/dir/"] (all directories named "dir"), ["!node_modules"] (exclude {rootDir}/node_modules). If omitted, includes all files matching other criteria. Supports standard glob syntax: * (any chars), ** (any dirs), ? (single char), [abc] (char class)'
|
|
@@ -1183,10 +1186,10 @@ const wt = h.object({
|
|
|
1183
1186
|
'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'
|
|
1184
1187
|
)
|
|
1185
1188
|
});
|
|
1186
|
-
async function
|
|
1189
|
+
async function Qr(r, t) {
|
|
1187
1190
|
let s;
|
|
1188
1191
|
try {
|
|
1189
|
-
s =
|
|
1192
|
+
s = bt.parse(r);
|
|
1190
1193
|
} catch (m) {
|
|
1191
1194
|
return {
|
|
1192
1195
|
error: F(m)
|
|
@@ -1216,13 +1219,13 @@ async function jr(t, r) {
|
|
|
1216
1219
|
};
|
|
1217
1220
|
}) ?? null;
|
|
1218
1221
|
(!d || d.length === 0) && (d = [{ field: "path", desc: !1 }]);
|
|
1219
|
-
const p = d?.map((m) => m.field) || [], g =
|
|
1220
|
-
|
|
1221
|
-
s.
|
|
1222
|
+
const p = d?.map((m) => m.field) || [], g = k.resolve(
|
|
1223
|
+
t.workingDir || "",
|
|
1224
|
+
s.relativeRootDir || ""
|
|
1222
1225
|
);
|
|
1223
1226
|
try {
|
|
1224
1227
|
try {
|
|
1225
|
-
await
|
|
1228
|
+
await j.promises.access(g, j.constants.F_OK);
|
|
1226
1229
|
} catch (x) {
|
|
1227
1230
|
if (x.code === "ENOENT")
|
|
1228
1231
|
return {
|
|
@@ -1234,7 +1237,7 @@ async function jr(t, r) {
|
|
|
1234
1237
|
value: x,
|
|
1235
1238
|
valueType: "pattern",
|
|
1236
1239
|
exclude: !1
|
|
1237
|
-
})) : [{ value: "**", valueType: "pattern", exclude: !1 }], y =
|
|
1240
|
+
})) : [{ value: "**", valueType: "pattern", exclude: !1 }], y = t.globsExclude || [], w = [...m, ...y], M = {
|
|
1238
1241
|
files: e ?? !1,
|
|
1239
1242
|
dirs: n ?? !1,
|
|
1240
1243
|
dateModified: f.includes("dateModified") || p.includes("dateModified"),
|
|
@@ -1244,7 +1247,7 @@ async function jr(t, r) {
|
|
|
1244
1247
|
let E = null, b = null;
|
|
1245
1248
|
if (a || c)
|
|
1246
1249
|
try {
|
|
1247
|
-
const x = Date.now(), T = c ? x -
|
|
1250
|
+
const x = Date.now(), T = c ? x - ze(c) : null, v = a ? x - ze(a) : null;
|
|
1248
1251
|
E = [T, v];
|
|
1249
1252
|
} catch (x) {
|
|
1250
1253
|
return {
|
|
@@ -1253,24 +1256,24 @@ async function jr(t, r) {
|
|
|
1253
1256
|
}
|
|
1254
1257
|
if (l || u)
|
|
1255
1258
|
try {
|
|
1256
|
-
const x = l ?
|
|
1259
|
+
const x = l ? Ue(l) : null, T = u ? Ue(u) : null;
|
|
1257
1260
|
b = [x, T];
|
|
1258
1261
|
} catch (x) {
|
|
1259
1262
|
return {
|
|
1260
1263
|
error: x instanceof Error ? x.message : "Unknown error parsing size filter"
|
|
1261
1264
|
};
|
|
1262
1265
|
}
|
|
1263
|
-
const $ = await
|
|
1266
|
+
const $ = await _r({
|
|
1264
1267
|
rootDir: g || null,
|
|
1265
1268
|
globs: w,
|
|
1266
1269
|
result: M,
|
|
1267
1270
|
dateModified: E,
|
|
1268
1271
|
totalSize: b
|
|
1269
1272
|
});
|
|
1270
|
-
return $.items.length >
|
|
1271
|
-
error: `Number of paths (${$.items.length}) exceeds maximum allowed (${
|
|
1273
|
+
return $.items.length > Ae ? {
|
|
1274
|
+
error: `Number of paths (${$.items.length}) exceeds maximum allowed (${Ae}). Consider using more specific glob patterns or filters to reduce the result set.`
|
|
1272
1275
|
} : {
|
|
1273
|
-
output:
|
|
1276
|
+
output: Kr($, {
|
|
1274
1277
|
sort: d,
|
|
1275
1278
|
fields: f,
|
|
1276
1279
|
totals: !0
|
|
@@ -1280,16 +1283,16 @@ async function jr(t, r) {
|
|
|
1280
1283
|
return { error: m instanceof Error ? m.message : "Unknown error" };
|
|
1281
1284
|
}
|
|
1282
1285
|
}
|
|
1283
|
-
function
|
|
1284
|
-
|
|
1286
|
+
function Yr(r, t) {
|
|
1287
|
+
r(
|
|
1285
1288
|
"fs-list",
|
|
1286
1289
|
{
|
|
1287
1290
|
title: "List Files and Directories",
|
|
1288
1291
|
description: "List files and directories with advanced filtering, sorting and formatting options. Use this to analyze filesystem structure",
|
|
1289
|
-
inputSchema:
|
|
1292
|
+
inputSchema: bt.shape
|
|
1290
1293
|
},
|
|
1291
1294
|
async (s) => {
|
|
1292
|
-
const o = await
|
|
1295
|
+
const o = await Qr(s, t);
|
|
1293
1296
|
return o.error ? `Method: fs-list(${JSON.stringify(s)})
|
|
1294
1297
|
❌ Error: ${o.error}` : `Method: fs-list(${JSON.stringify(s)})
|
|
1295
1298
|
${o.output || JSON.stringify(o, null, 2)}`;
|
|
@@ -1297,27 +1300,27 @@ ${o.output || JSON.stringify(o, null, 2)}`;
|
|
|
1297
1300
|
);
|
|
1298
1301
|
}
|
|
1299
1302
|
const ue = /* @__PURE__ */ new Map();
|
|
1300
|
-
let
|
|
1301
|
-
function
|
|
1302
|
-
return `${++
|
|
1303
|
+
let Vr = 0;
|
|
1304
|
+
function Zr() {
|
|
1305
|
+
return `${++Vr}-${Math.random().toString(36).slice(2)}`;
|
|
1303
1306
|
}
|
|
1304
|
-
function Z(
|
|
1305
|
-
return ue.has(
|
|
1307
|
+
function Z(r) {
|
|
1308
|
+
return ue.has(r) || ue.set(r, {
|
|
1306
1309
|
fsSnapshotQueries: /* @__PURE__ */ new Map(),
|
|
1307
1310
|
fsSnapshots: /* @__PURE__ */ new Map(),
|
|
1308
1311
|
preparedReplace: null
|
|
1309
|
-
}), ue.get(
|
|
1312
|
+
}), ue.get(r);
|
|
1310
1313
|
}
|
|
1311
|
-
function
|
|
1312
|
-
const
|
|
1314
|
+
function je(r) {
|
|
1315
|
+
const t = r.match(
|
|
1313
1316
|
/^\s*(\d+(?:\.\d+)?)\s*([smhdwMY]|sec(onds?)?|min(utes?)?|hours?|days?|weeks?|months?|years?)\s*$/i
|
|
1314
1317
|
);
|
|
1315
|
-
if (!
|
|
1318
|
+
if (!t)
|
|
1316
1319
|
throw new Error(
|
|
1317
|
-
`Invalid time ago format: "${
|
|
1320
|
+
`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).`
|
|
1318
1321
|
);
|
|
1319
|
-
const s = parseFloat(
|
|
1320
|
-
let o =
|
|
1322
|
+
const s = parseFloat(t[1]);
|
|
1323
|
+
let o = t[2];
|
|
1321
1324
|
switch (o !== "M" && (o = o.toLowerCase(), o.startsWith("month") ? o = "M" : o.length > 1 && (o = o[0])), o) {
|
|
1322
1325
|
case "s":
|
|
1323
1326
|
return s * 1e3;
|
|
@@ -1339,13 +1342,13 @@ function Ue(t) {
|
|
|
1339
1342
|
);
|
|
1340
1343
|
}
|
|
1341
1344
|
}
|
|
1342
|
-
function qe(
|
|
1343
|
-
const
|
|
1344
|
-
if (!
|
|
1345
|
+
function qe(r) {
|
|
1346
|
+
const t = r.match(/^\s*(\d+(?:\.\d+)?)\s*(B|KB|MB|GB|TB)\s*$/i);
|
|
1347
|
+
if (!t)
|
|
1345
1348
|
throw new Error(
|
|
1346
|
-
`Invalid size format: "${
|
|
1349
|
+
`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.`
|
|
1347
1350
|
);
|
|
1348
|
-
const s = parseFloat(
|
|
1351
|
+
const s = parseFloat(t[1]), o = t[2].toUpperCase();
|
|
1349
1352
|
switch (o) {
|
|
1350
1353
|
case "B":
|
|
1351
1354
|
return s;
|
|
@@ -1367,8 +1370,8 @@ const Se = h.object({
|
|
|
1367
1370
|
name: h.string().describe(
|
|
1368
1371
|
"Unique name for the filesystem snapshot query. Recommended format: kebab-case-1, kebab-case-2, ..."
|
|
1369
1372
|
),
|
|
1370
|
-
|
|
1371
|
-
'
|
|
1373
|
+
relativeRootDir: h.string().optional().describe(
|
|
1374
|
+
'Relative path from project root to directory for snapshot. Use forward slashes. Leave empty for project root. Examples: "src", "src/components", "tests". Path must exist'
|
|
1372
1375
|
),
|
|
1373
1376
|
bulkGlobs: h.array(h.string()).optional().describe(
|
|
1374
1377
|
'Glob patterns to filter files/directories. Include all patterns in this single array; never split across multiple tool calls. Add leading ** for recursive matching. Examples: ["**/*.js"], ["src/**/*.ts"], ["**/*.{ts,svelte}"], ["!node_modules"]. If omitted, includes all files matching other criteria. Supports: * (any chars), ** (any dirs), ? (single char), [abc] (char class)'
|
|
@@ -1398,16 +1401,16 @@ const Se = h.object({
|
|
|
1398
1401
|
"countMatched",
|
|
1399
1402
|
"size",
|
|
1400
1403
|
"dateModified"
|
|
1401
|
-
].map((
|
|
1404
|
+
].map((r, t) => [r, t])
|
|
1402
1405
|
);
|
|
1403
|
-
function
|
|
1404
|
-
const s = Ge.get(
|
|
1406
|
+
function Xr(r, t) {
|
|
1407
|
+
const s = Ge.get(r) ?? 1 / 0, o = Ge.get(t) ?? 1 / 0;
|
|
1405
1408
|
return s > o ? 1 : s < o ? -1 : 0;
|
|
1406
1409
|
}
|
|
1407
|
-
async function
|
|
1410
|
+
async function St(r, t, s) {
|
|
1408
1411
|
let o;
|
|
1409
1412
|
try {
|
|
1410
|
-
o = Se.parse(
|
|
1413
|
+
o = Se.parse(r);
|
|
1411
1414
|
} catch (p) {
|
|
1412
1415
|
return {
|
|
1413
1416
|
error: F(p)
|
|
@@ -1427,11 +1430,11 @@ async function yt(t, r, s) {
|
|
|
1427
1430
|
error: "Session ID is required"
|
|
1428
1431
|
};
|
|
1429
1432
|
const f = Z(s.sessionId), d = H(
|
|
1430
|
-
|
|
1433
|
+
k.resolve(t.workingDir || "", o.relativeRootDir || "")
|
|
1431
1434
|
);
|
|
1432
1435
|
try {
|
|
1433
1436
|
try {
|
|
1434
|
-
await
|
|
1437
|
+
await j.promises.access(d, j.constants.F_OK);
|
|
1435
1438
|
} catch (S) {
|
|
1436
1439
|
if (S.code === "ENOENT")
|
|
1437
1440
|
return {
|
|
@@ -1440,16 +1443,16 @@ async function yt(t, r, s) {
|
|
|
1440
1443
|
throw S;
|
|
1441
1444
|
}
|
|
1442
1445
|
const p = o.extraFields ? o.extraFields.map((S) => S === "lastModified" ? "dateModified" : S) : [];
|
|
1443
|
-
p.includes("name") || p.push("name"), p.sort(
|
|
1446
|
+
p.includes("name") || p.push("name"), p.sort(Xr);
|
|
1444
1447
|
const g = n && n.length > 0 ? n.map((S) => ({
|
|
1445
1448
|
value: S,
|
|
1446
1449
|
valueType: "pattern",
|
|
1447
1450
|
exclude: !1
|
|
1448
|
-
})) : [{ value: "**", valueType: "pattern", exclude: !1 }], m =
|
|
1451
|
+
})) : [{ value: "**", valueType: "pattern", exclude: !1 }], m = t.globsExclude || [], y = [...g, ...m];
|
|
1449
1452
|
let w = null, M = null;
|
|
1450
1453
|
if (a || c)
|
|
1451
1454
|
try {
|
|
1452
|
-
const S = Date.now(), x = c ? S -
|
|
1455
|
+
const S = Date.now(), x = c ? S - je(c) : null, T = a ? S - je(a) : null;
|
|
1453
1456
|
w = [x, T];
|
|
1454
1457
|
} catch (S) {
|
|
1455
1458
|
return {
|
|
@@ -1484,8 +1487,8 @@ async function yt(t, r, s) {
|
|
|
1484
1487
|
};
|
|
1485
1488
|
}
|
|
1486
1489
|
}
|
|
1487
|
-
function
|
|
1488
|
-
|
|
1490
|
+
function es(r, t) {
|
|
1491
|
+
r(
|
|
1489
1492
|
"fs-snapshot-query-create",
|
|
1490
1493
|
{
|
|
1491
1494
|
title: "Create Filesystem Snapshot Query",
|
|
@@ -1493,21 +1496,21 @@ function Yr(t, r) {
|
|
|
1493
1496
|
inputSchema: Se.shape
|
|
1494
1497
|
},
|
|
1495
1498
|
async (s, o) => {
|
|
1496
|
-
const e = await
|
|
1499
|
+
const e = await St(s, t, o);
|
|
1497
1500
|
return e.error != null ? `Method: fs-snapshot-query-create(${JSON.stringify(s)})
|
|
1498
1501
|
❌ Error: ${e.error}` : `Method: fs-snapshot-query-create(${JSON.stringify(s)})
|
|
1499
1502
|
✅ Filesystem snapshot query "${e.snapshotQuery.name}" created successfully`;
|
|
1500
1503
|
}
|
|
1501
1504
|
);
|
|
1502
1505
|
}
|
|
1503
|
-
function le(
|
|
1504
|
-
const { idToNode:
|
|
1506
|
+
function le(r) {
|
|
1507
|
+
const { idToNode: t, idToChildIds: s } = r, o = t.get(null);
|
|
1505
1508
|
if (o == null)
|
|
1506
1509
|
throw new Error(
|
|
1507
1510
|
"Impossible behavior: root node (id: null) not found in idToNode"
|
|
1508
1511
|
);
|
|
1509
1512
|
const e = /* @__PURE__ */ new Map();
|
|
1510
|
-
return
|
|
1513
|
+
return t.forEach((n, i) => {
|
|
1511
1514
|
if (n != null) {
|
|
1512
1515
|
if (e.has(n)) {
|
|
1513
1516
|
const a = e.get(n);
|
|
@@ -1519,18 +1522,18 @@ function le(t) {
|
|
|
1519
1522
|
}
|
|
1520
1523
|
}), {
|
|
1521
1524
|
root: o,
|
|
1522
|
-
getNode: (n) =>
|
|
1525
|
+
getNode: (n) => t.get(n) ?? null,
|
|
1523
1526
|
getId: (n) => e.get(n) ?? null,
|
|
1524
1527
|
getChilds: (n) => {
|
|
1525
1528
|
let i = e.get(n);
|
|
1526
1529
|
if (i == null)
|
|
1527
|
-
if (n ===
|
|
1530
|
+
if (n === t.get(null))
|
|
1528
1531
|
i = null;
|
|
1529
1532
|
else
|
|
1530
1533
|
throw new Error("Impossible behavior: node not found in idToNode");
|
|
1531
1534
|
const a = s.get(i);
|
|
1532
1535
|
return a == null ? null : a.map((c) => {
|
|
1533
|
-
const l =
|
|
1536
|
+
const l = t.get(c);
|
|
1534
1537
|
if (l == null)
|
|
1535
1538
|
throw new Error(
|
|
1536
1539
|
`Child node with id '${c}' not found in idToNode`
|
|
@@ -1540,22 +1543,22 @@ function le(t) {
|
|
|
1540
1543
|
}
|
|
1541
1544
|
};
|
|
1542
1545
|
}
|
|
1543
|
-
function
|
|
1546
|
+
function xt(r, t, s) {
|
|
1544
1547
|
let o = null;
|
|
1545
|
-
for (let e = 0, n =
|
|
1546
|
-
const i =
|
|
1548
|
+
for (let e = 0, n = t.length; e < n; e++) {
|
|
1549
|
+
const i = t[e], a = r(i), c = a == null ? null : xt(r, a, s), l = s(i, c);
|
|
1547
1550
|
l != null && (o == null && (o = []), o.push(l));
|
|
1548
1551
|
}
|
|
1549
1552
|
return o;
|
|
1550
1553
|
}
|
|
1551
|
-
function
|
|
1552
|
-
const { getId:
|
|
1554
|
+
function $t(r) {
|
|
1555
|
+
const { getId: t, getChilds: s, rootNodes: o, createSnapshotNode: e } = r, n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), c = xt(
|
|
1553
1556
|
s,
|
|
1554
1557
|
o,
|
|
1555
1558
|
(u, f) => {
|
|
1556
1559
|
const d = e(u, f);
|
|
1557
1560
|
if (u != null && d != null) {
|
|
1558
|
-
const p =
|
|
1561
|
+
const p = t(u);
|
|
1559
1562
|
n.set(p, d), i.set(d, p);
|
|
1560
1563
|
}
|
|
1561
1564
|
return d != null && f != null && a.set(
|
|
@@ -1574,43 +1577,43 @@ function St(t) {
|
|
|
1574
1577
|
idToChildIds: a
|
|
1575
1578
|
};
|
|
1576
1579
|
}
|
|
1577
|
-
function me(
|
|
1578
|
-
return
|
|
1580
|
+
function me(r) {
|
|
1581
|
+
return r = r != null ? H(r).replace(/\/$/, "") : null, !r || r === "." ? null : r;
|
|
1579
1582
|
}
|
|
1580
|
-
async function
|
|
1581
|
-
const
|
|
1583
|
+
async function ts(r) {
|
|
1584
|
+
const t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), o = k.resolve(r.rootDir || "."), n = {
|
|
1582
1585
|
path: ".",
|
|
1583
|
-
name:
|
|
1586
|
+
name: k.basename(o),
|
|
1584
1587
|
type: "dir",
|
|
1585
1588
|
isMatched: !1,
|
|
1586
1589
|
dateModified: null,
|
|
1587
1590
|
size: 0
|
|
1588
1591
|
};
|
|
1589
|
-
|
|
1590
|
-
const i = await
|
|
1592
|
+
t.set(null, n);
|
|
1593
|
+
const i = await wt({
|
|
1591
1594
|
rootDir: o,
|
|
1592
|
-
globs:
|
|
1595
|
+
globs: r.globs
|
|
1593
1596
|
});
|
|
1594
|
-
return await
|
|
1597
|
+
return await gt({
|
|
1595
1598
|
paths: [o],
|
|
1596
1599
|
walkLinks: !0,
|
|
1597
|
-
matchPath:
|
|
1600
|
+
matchPath: yt({
|
|
1598
1601
|
globs: i,
|
|
1599
1602
|
rootDir: o,
|
|
1600
1603
|
noCase: !0
|
|
1601
1604
|
}),
|
|
1602
1605
|
handlePath: async ({ path: a, stat: c, itemStat: l }) => {
|
|
1603
|
-
const u =
|
|
1606
|
+
const u = k.relative(o, a), f = c.isDirectory(), d = c.isFile();
|
|
1604
1607
|
if (!f && !d)
|
|
1605
1608
|
return !0;
|
|
1606
1609
|
const p = me(u || "."), g = f ? "dir" : "file", m = f ? null : c.mtimeMs, y = c.size;
|
|
1607
1610
|
let w = !0;
|
|
1608
|
-
if (d && !
|
|
1609
|
-
const [$, S] =
|
|
1611
|
+
if (d && !r.matchFiles && (w = !1), f && !r.matchDirs && (w = !1), w && d && r.dateModified && m != null) {
|
|
1612
|
+
const [$, S] = r.dateModified;
|
|
1610
1613
|
($ != null && m < $ || S != null && m > S) && (w = !1);
|
|
1611
1614
|
}
|
|
1612
|
-
if (w && d &&
|
|
1613
|
-
const [$, S] =
|
|
1615
|
+
if (w && d && r.totalSize && y != null) {
|
|
1616
|
+
const [$, S] = r.totalSize;
|
|
1614
1617
|
($ != null && y < $ || S != null && y > S) && (w = !1);
|
|
1615
1618
|
}
|
|
1616
1619
|
if (f && !w) {
|
|
@@ -1619,7 +1622,7 @@ async function Vr(t) {
|
|
|
1619
1622
|
return !1;
|
|
1620
1623
|
const M = {
|
|
1621
1624
|
path: p ?? ".",
|
|
1622
|
-
name:
|
|
1625
|
+
name: k.basename(a),
|
|
1623
1626
|
type: g,
|
|
1624
1627
|
dateModified: m,
|
|
1625
1628
|
size: y,
|
|
@@ -1627,26 +1630,26 @@ async function Vr(t) {
|
|
|
1627
1630
|
};
|
|
1628
1631
|
if (p == null)
|
|
1629
1632
|
return n.dateModified = m, n.size = y, n.isMatched = w, !0;
|
|
1630
|
-
|
|
1631
|
-
const E = me(H(
|
|
1633
|
+
t.set(p, M);
|
|
1634
|
+
const E = me(H(k.dirname(p)));
|
|
1632
1635
|
let b = s.get(E);
|
|
1633
1636
|
return b || (b = [], s.set(E, b)), b.push(p), !0;
|
|
1634
1637
|
}
|
|
1635
1638
|
}), {
|
|
1636
|
-
idToNode:
|
|
1639
|
+
idToNode: t,
|
|
1637
1640
|
idToChildIds: s
|
|
1638
1641
|
};
|
|
1639
1642
|
}
|
|
1640
|
-
const
|
|
1641
|
-
{ name: "[ ]", match: (
|
|
1642
|
-
{ name: "[\\t]", match: (
|
|
1643
|
-
{ name: "[\\n]", match: (
|
|
1644
|
-
{ name: "[-]", match: (
|
|
1645
|
-
{ name: "[=]", match: (
|
|
1646
|
-
{ name: "[_]", match: (
|
|
1647
|
-
{ name: "[*]", match: (
|
|
1648
|
-
{ name: "[.]", match: (
|
|
1649
|
-
{ name: "[0-9]", match: (
|
|
1643
|
+
const rs = [
|
|
1644
|
+
{ name: "[ ]", match: (r) => r === 32, min: 2, max: 81 },
|
|
1645
|
+
{ name: "[\\t]", match: (r) => r === 9, min: 2, max: 20 },
|
|
1646
|
+
{ name: "[\\n]", match: (r) => r === 10, min: 2, max: 14 },
|
|
1647
|
+
{ name: "[-]", match: (r) => r === 45, min: 2, max: 16 },
|
|
1648
|
+
{ name: "[=]", match: (r) => r === 61, min: 2, max: 16 },
|
|
1649
|
+
{ name: "[_]", match: (r) => r === 95, min: 2, max: 16 },
|
|
1650
|
+
{ name: "[*]", match: (r) => r === 42, min: 2, max: 16 },
|
|
1651
|
+
{ name: "[.]", match: (r) => r === 46, min: 2, max: 16 },
|
|
1652
|
+
{ name: "[0-9]", match: (r) => r >= 48 && r <= 57, min: 2, max: 3 }
|
|
1650
1653
|
// { name: '[a-z]', match: c => c >= 97 && c <= 122, min: 2, max: 2 },
|
|
1651
1654
|
// { name: '[A-Z]', match: c => c >= 65 && c <= 90, min: 2, max: 2 },
|
|
1652
1655
|
// Other ASCII symbols
|
|
@@ -1660,21 +1663,21 @@ const Zr = [
|
|
|
1660
1663
|
// max: 2,
|
|
1661
1664
|
// },
|
|
1662
1665
|
];
|
|
1663
|
-
function _e(
|
|
1664
|
-
const s =
|
|
1666
|
+
function _e(r, t = rs) {
|
|
1667
|
+
const s = r.length;
|
|
1665
1668
|
if (s === 0) return 0;
|
|
1666
|
-
const o =
|
|
1669
|
+
const o = t.length;
|
|
1667
1670
|
if (o === 0)
|
|
1668
1671
|
return s;
|
|
1669
1672
|
let e = 0, n = 0;
|
|
1670
1673
|
for (; n < s; ) {
|
|
1671
|
-
const i =
|
|
1674
|
+
const i = r.charCodeAt(n);
|
|
1672
1675
|
let a = !1;
|
|
1673
1676
|
for (let c = 0; c < o; c++) {
|
|
1674
|
-
const l =
|
|
1677
|
+
const l = t[c];
|
|
1675
1678
|
if (l.match(i)) {
|
|
1676
1679
|
let u = 1;
|
|
1677
|
-
for (; ++n < s && l.match(
|
|
1680
|
+
for (; ++n < s && l.match(r.charCodeAt(n)) && u < l.max; )
|
|
1678
1681
|
u++;
|
|
1679
1682
|
if (u >= l.min) {
|
|
1680
1683
|
e++, a = !0;
|
|
@@ -1686,27 +1689,27 @@ function _e(t, r = Zr) {
|
|
|
1686
1689
|
}
|
|
1687
1690
|
return e;
|
|
1688
1691
|
}
|
|
1689
|
-
function
|
|
1690
|
-
let
|
|
1691
|
-
return
|
|
1692
|
+
function It(r) {
|
|
1693
|
+
let t = 0;
|
|
1694
|
+
return t += _e(r.textOpen) + 1, r.textClose != null && (t += _e(r.textClose) + 1), r.indent && (t += 1), t;
|
|
1692
1695
|
}
|
|
1693
|
-
const Je = ["B", "KB", "MB", "GB", "TB"],
|
|
1694
|
-
function
|
|
1695
|
-
if (
|
|
1696
|
-
let
|
|
1697
|
-
for (;
|
|
1698
|
-
|
|
1699
|
-
return `${s === 0 ?
|
|
1696
|
+
const Je = ["B", "KB", "MB", "GB", "TB"], Ke = 1024;
|
|
1697
|
+
function ss(r) {
|
|
1698
|
+
if (r == null) return "-";
|
|
1699
|
+
let t = r ?? 0, s = 0;
|
|
1700
|
+
for (; t >= Ke && s < Je.length - 1; )
|
|
1701
|
+
t /= Ke, s++;
|
|
1702
|
+
return `${s === 0 ? t.toString() : t.toFixed(2)}${Je[s]}`;
|
|
1700
1703
|
}
|
|
1701
|
-
function
|
|
1702
|
-
const s = Date.now() -
|
|
1704
|
+
function os(r) {
|
|
1705
|
+
const s = Date.now() - r;
|
|
1703
1706
|
if (s < 0) return "0s";
|
|
1704
1707
|
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);
|
|
1705
1708
|
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`;
|
|
1706
1709
|
}
|
|
1707
|
-
function
|
|
1710
|
+
function ns(r) {
|
|
1708
1711
|
return function(s, o) {
|
|
1709
|
-
const e =
|
|
1712
|
+
const e = r.get(s), n = r.get(o);
|
|
1710
1713
|
if (e.type !== n.type)
|
|
1711
1714
|
return e.type === "file" ? -1 : 1;
|
|
1712
1715
|
if (e.type === "file")
|
|
@@ -1717,8 +1720,8 @@ function ts(t) {
|
|
|
1717
1720
|
}
|
|
1718
1721
|
};
|
|
1719
1722
|
}
|
|
1720
|
-
function
|
|
1721
|
-
const
|
|
1723
|
+
function is(r) {
|
|
1724
|
+
const t = r.fields ?? [];
|
|
1722
1725
|
return function(o, e) {
|
|
1723
1726
|
let n = "", i, a = 0;
|
|
1724
1727
|
const c = e ? e.length : 0;
|
|
@@ -1729,14 +1732,14 @@ function rs(t) {
|
|
|
1729
1732
|
a += $.countMatched, l += $.countTotal, f += $.tokens, d += $.tokensTotal, p += $.size, g += $.countFiles, $.dateModified != null && (m == null || $.dateModified > m) && (m = $.dateModified);
|
|
1730
1733
|
}
|
|
1731
1734
|
o ? (y = o.type, w = o.name, M = o.path, i = o.isMatched, i && (a += 1), o.type === "file" ? (p = o.size || 0, g = 1, m = o.dateModified || null) : o.dateModified != null && (m == null || o.dateModified > m) && (m = o.dateModified)) : (y = "dir", w = "<root>", M = ".", i = !0);
|
|
1732
|
-
for (let b = 0, $ =
|
|
1733
|
-
const S =
|
|
1735
|
+
for (let b = 0, $ = t.length; b < $; b++) {
|
|
1736
|
+
const S = t[b];
|
|
1734
1737
|
switch (b > 0 && (n += " "), S) {
|
|
1735
1738
|
case "dateModified":
|
|
1736
|
-
n += m ?
|
|
1739
|
+
n += m ? os(m) : "-";
|
|
1737
1740
|
break;
|
|
1738
1741
|
case "size":
|
|
1739
|
-
n +=
|
|
1742
|
+
n += ss(p);
|
|
1740
1743
|
break;
|
|
1741
1744
|
case "type":
|
|
1742
1745
|
n += y;
|
|
@@ -1754,7 +1757,7 @@ function rs(t) {
|
|
|
1754
1757
|
textOpen: n,
|
|
1755
1758
|
textClose: null
|
|
1756
1759
|
};
|
|
1757
|
-
return u =
|
|
1760
|
+
return u = It(E), d += u, {
|
|
1758
1761
|
type: y,
|
|
1759
1762
|
name: w,
|
|
1760
1763
|
path: M,
|
|
@@ -1772,8 +1775,8 @@ function rs(t) {
|
|
|
1772
1775
|
};
|
|
1773
1776
|
};
|
|
1774
1777
|
}
|
|
1775
|
-
async function
|
|
1776
|
-
const
|
|
1778
|
+
async function as(r) {
|
|
1779
|
+
const t = await ts(r), s = le(t), o = s.getChilds(s.root), e = $t({
|
|
1777
1780
|
getId: (i) => {
|
|
1778
1781
|
const a = s.getId(i);
|
|
1779
1782
|
if (a == null)
|
|
@@ -1783,9 +1786,9 @@ async function ss(t) {
|
|
|
1783
1786
|
return a;
|
|
1784
1787
|
},
|
|
1785
1788
|
getChilds: (i) => s.getChilds(i),
|
|
1786
|
-
createSnapshotNode:
|
|
1789
|
+
createSnapshotNode: is(r),
|
|
1787
1790
|
rootNodes: o ?? []
|
|
1788
|
-
}), n =
|
|
1791
|
+
}), n = ns(e.idToNode);
|
|
1789
1792
|
return e.idToChildIds.forEach((i) => {
|
|
1790
1793
|
i.sort(n);
|
|
1791
1794
|
}), le(e);
|
|
@@ -1799,10 +1802,10 @@ const ee = h.object({
|
|
|
1799
1802
|
"Unique name for the filesystem snapshot. Recommended format: kebab-case-1, kebab-case-2, ..."
|
|
1800
1803
|
)
|
|
1801
1804
|
});
|
|
1802
|
-
async function ce(
|
|
1805
|
+
async function ce(r, t, s) {
|
|
1803
1806
|
let o;
|
|
1804
1807
|
try {
|
|
1805
|
-
o = ee.parse(
|
|
1808
|
+
o = ee.parse(r);
|
|
1806
1809
|
} catch (u) {
|
|
1807
1810
|
return {
|
|
1808
1811
|
error: F(u)
|
|
@@ -1827,9 +1830,9 @@ async function ce(t, r, s) {
|
|
|
1827
1830
|
};
|
|
1828
1831
|
c = u;
|
|
1829
1832
|
} else if (i) {
|
|
1830
|
-
const u = await
|
|
1833
|
+
const u = await St(
|
|
1831
1834
|
i,
|
|
1832
|
-
|
|
1835
|
+
t,
|
|
1833
1836
|
s
|
|
1834
1837
|
);
|
|
1835
1838
|
if (u.error != null)
|
|
@@ -1842,7 +1845,7 @@ async function ce(t, r, s) {
|
|
|
1842
1845
|
error: "Either queryName or query must be provided"
|
|
1843
1846
|
};
|
|
1844
1847
|
try {
|
|
1845
|
-
const u = await
|
|
1848
|
+
const u = await as(c), f = {
|
|
1846
1849
|
name: e,
|
|
1847
1850
|
query: c,
|
|
1848
1851
|
tree: u
|
|
@@ -1857,8 +1860,8 @@ async function ce(t, r, s) {
|
|
|
1857
1860
|
};
|
|
1858
1861
|
}
|
|
1859
1862
|
}
|
|
1860
|
-
function
|
|
1861
|
-
|
|
1863
|
+
function ls(r, t) {
|
|
1864
|
+
r(
|
|
1862
1865
|
"fs-snapshot-create",
|
|
1863
1866
|
{
|
|
1864
1867
|
title: "Create Filesystem Snapshot",
|
|
@@ -1866,7 +1869,7 @@ function os(t, r) {
|
|
|
1866
1869
|
inputSchema: ee.shape
|
|
1867
1870
|
},
|
|
1868
1871
|
async (s, o) => {
|
|
1869
|
-
const e = await ce(s,
|
|
1872
|
+
const e = await ce(s, t, o);
|
|
1870
1873
|
if (e.error != null)
|
|
1871
1874
|
return `Method: fs-snapshot-create(${JSON.stringify(s)})
|
|
1872
1875
|
❌ Error: ${e.error}`;
|
|
@@ -1877,18 +1880,18 @@ function os(t, r) {
|
|
|
1877
1880
|
}
|
|
1878
1881
|
);
|
|
1879
1882
|
}
|
|
1880
|
-
class
|
|
1883
|
+
class cs {
|
|
1881
1884
|
_first = null;
|
|
1882
1885
|
_last = null;
|
|
1883
1886
|
_size = 0;
|
|
1884
|
-
enqueue(
|
|
1885
|
-
const s = { item:
|
|
1887
|
+
enqueue(t) {
|
|
1888
|
+
const s = { item: t, next: null };
|
|
1886
1889
|
this._last ? this._last.next = s : this._first = s, this._last = s, this._size += 1;
|
|
1887
1890
|
}
|
|
1888
1891
|
dequeue() {
|
|
1889
1892
|
if (!this._first) return null;
|
|
1890
|
-
const
|
|
1891
|
-
return this._first = this._first.next, this._first || (this._last = null), this._size -= 1,
|
|
1893
|
+
const t = this._first.item;
|
|
1894
|
+
return this._first = this._first.next, this._first || (this._last = null), this._size -= 1, t;
|
|
1892
1895
|
}
|
|
1893
1896
|
peek() {
|
|
1894
1897
|
return this._first ? this._first.item : null;
|
|
@@ -1900,24 +1903,24 @@ class ns {
|
|
|
1900
1903
|
return this._size;
|
|
1901
1904
|
}
|
|
1902
1905
|
}
|
|
1903
|
-
function
|
|
1904
|
-
const
|
|
1906
|
+
function us(r) {
|
|
1907
|
+
const t = new cs(), {
|
|
1905
1908
|
tree: s,
|
|
1906
1909
|
limits: { maxCountTotal: o, maxTokensTotal: e, maxCountGroup: n, maxTokensGroup: i },
|
|
1907
1910
|
indexRangeGroupStrategy: a
|
|
1908
|
-
} =
|
|
1909
|
-
c != null && c.length > 0 &&
|
|
1911
|
+
} = r, c = s.getChilds(s.root);
|
|
1912
|
+
c != null && c.length > 0 && t.enqueue({
|
|
1910
1913
|
reportNode: null,
|
|
1911
1914
|
node: s.root
|
|
1912
1915
|
});
|
|
1913
1916
|
let l = null, u = 0, f = 0;
|
|
1914
|
-
for (; !
|
|
1915
|
-
const { reportNode: d, node: p } =
|
|
1917
|
+
for (; !t.isEmpty(); ) {
|
|
1918
|
+
const { reportNode: d, node: p } = t.dequeue(), g = s.getChilds(p);
|
|
1916
1919
|
if (g == null || p.countChilds === 0 || g.length !== p.countChilds)
|
|
1917
1920
|
throw new Error(
|
|
1918
1921
|
"Impossible behavior: nodeChilds is null or length mismatch"
|
|
1919
1922
|
);
|
|
1920
|
-
let m =
|
|
1923
|
+
let m = t.size();
|
|
1921
1924
|
for (let w = 0; w < g.length; w++)
|
|
1922
1925
|
g[w].countChilds > 0 && (m += 1);
|
|
1923
1926
|
const y = m * a.tokens;
|
|
@@ -1951,7 +1954,7 @@ function is(t) {
|
|
|
1951
1954
|
};
|
|
1952
1955
|
w.push(b);
|
|
1953
1956
|
const $ = s.getChilds(E);
|
|
1954
|
-
$ != null && $.length > 0 &&
|
|
1957
|
+
$ != null && $.length > 0 && t.enqueue({
|
|
1955
1958
|
reportNode: b,
|
|
1956
1959
|
node: E
|
|
1957
1960
|
});
|
|
@@ -1969,22 +1972,22 @@ function is(t) {
|
|
|
1969
1972
|
}
|
|
1970
1973
|
return l ?? [];
|
|
1971
1974
|
}
|
|
1972
|
-
function
|
|
1975
|
+
function Mt(r) {
|
|
1973
1976
|
const {
|
|
1974
|
-
tree:
|
|
1977
|
+
tree: t,
|
|
1975
1978
|
request: { parentNodeId: s, childsIndexRange: o, limits: e },
|
|
1976
1979
|
indexRangeGroupStrategy: n,
|
|
1977
1980
|
...i
|
|
1978
|
-
} =
|
|
1981
|
+
} = r;
|
|
1979
1982
|
let a;
|
|
1980
1983
|
if (s != null) {
|
|
1981
|
-
const d =
|
|
1984
|
+
const d = t.getNode(s);
|
|
1982
1985
|
if (d == null)
|
|
1983
1986
|
throw new Error(`Parent node "${s}" not found`);
|
|
1984
1987
|
a = d;
|
|
1985
1988
|
} else
|
|
1986
|
-
a =
|
|
1987
|
-
let c, l =
|
|
1989
|
+
a = t.root;
|
|
1990
|
+
let c, l = t.getChilds(a) ?? [];
|
|
1988
1991
|
if (o != null) {
|
|
1989
1992
|
const [d, p] = o;
|
|
1990
1993
|
if (d < 0 || p <= d || p >= l.length)
|
|
@@ -2009,19 +2012,19 @@ function $t(t) {
|
|
|
2009
2012
|
countChilds: 1,
|
|
2010
2013
|
tokensChilds: c.tokens
|
|
2011
2014
|
}, f = {
|
|
2012
|
-
...
|
|
2015
|
+
...t,
|
|
2013
2016
|
root: u,
|
|
2014
|
-
getChilds: (d) => d === u ? [c] : d === c ? l :
|
|
2017
|
+
getChilds: (d) => d === u ? [c] : d === c ? l : t.getChilds(d)
|
|
2015
2018
|
};
|
|
2016
|
-
return
|
|
2019
|
+
return us({
|
|
2017
2020
|
tree: f,
|
|
2018
2021
|
limits: e,
|
|
2019
2022
|
indexRangeGroupStrategy: n,
|
|
2020
2023
|
...i
|
|
2021
2024
|
});
|
|
2022
2025
|
}
|
|
2023
|
-
function
|
|
2024
|
-
if (
|
|
2026
|
+
function Tt(r, t) {
|
|
2027
|
+
if (r == null || r.length === 0)
|
|
2025
2028
|
return "No results found";
|
|
2026
2029
|
let s = "";
|
|
2027
2030
|
function o(e, n) {
|
|
@@ -2035,24 +2038,24 @@ function It(t, r) {
|
|
|
2035
2038
|
`);
|
|
2036
2039
|
}
|
|
2037
2040
|
}
|
|
2038
|
-
return o(
|
|
2041
|
+
return o(r, ""), s;
|
|
2039
2042
|
}
|
|
2040
|
-
class
|
|
2043
|
+
class ds {
|
|
2041
2044
|
tokens = 16;
|
|
2042
2045
|
// +1 indent, +1 for line break
|
|
2043
|
-
getReportText = (
|
|
2046
|
+
getReportText = (t) => ({
|
|
2044
2047
|
indent: !0,
|
|
2045
|
-
textOpen: `[${
|
|
2048
|
+
textOpen: `[${t.indexRange[0]}-${t.indexRange[1]}] see more ${t.countMatched} matched ${t.tokensGrouped} tokens`,
|
|
2046
2049
|
textClose: null
|
|
2047
2050
|
});
|
|
2048
|
-
add = (
|
|
2051
|
+
add = (t, s, o) => t == null ? {
|
|
2049
2052
|
indexRange: [o, o],
|
|
2050
2053
|
countGrouped: 1,
|
|
2051
2054
|
countMatched: s.countMatched,
|
|
2052
2055
|
tokensGrouped: s.tokens
|
|
2053
|
-
} : (
|
|
2056
|
+
} : (t.indexRange[1] = o, t.countGrouped += 1, t.countMatched += s.countMatched, t.tokensGrouped += s.tokens, t);
|
|
2054
2057
|
}
|
|
2055
|
-
const
|
|
2058
|
+
const Ct = h.object({
|
|
2056
2059
|
snapshotName: h.string().optional().describe("Name of previously created filesystem snapshot, to use"),
|
|
2057
2060
|
snapshot: ee.optional().describe(
|
|
2058
2061
|
"Filesystem snapshot creation options JSON to automatically create snapshot"
|
|
@@ -2074,10 +2077,10 @@ const Mt = h.object({
|
|
|
2074
2077
|
// maxCountGroup: z.number().default(10).describe('Maximum items per group'),
|
|
2075
2078
|
// maxTokensGroup: z.number().default(1000).describe('Maximum tokens per group'),
|
|
2076
2079
|
});
|
|
2077
|
-
async function
|
|
2080
|
+
async function fs(r, t, s) {
|
|
2078
2081
|
let o;
|
|
2079
2082
|
try {
|
|
2080
|
-
o =
|
|
2083
|
+
o = Ct.parse(r);
|
|
2081
2084
|
} catch (m) {
|
|
2082
2085
|
return {
|
|
2083
2086
|
error: F(m)
|
|
@@ -2110,7 +2113,7 @@ async function ls(t, r, s) {
|
|
|
2110
2113
|
} else if (n) {
|
|
2111
2114
|
const m = await ce(
|
|
2112
2115
|
n,
|
|
2113
|
-
|
|
2116
|
+
t,
|
|
2114
2117
|
s
|
|
2115
2118
|
);
|
|
2116
2119
|
if (m.error != null)
|
|
@@ -2123,7 +2126,7 @@ async function ls(t, r, s) {
|
|
|
2123
2126
|
error: "Either snapshotName or snapshot must be provided"
|
|
2124
2127
|
};
|
|
2125
2128
|
try {
|
|
2126
|
-
const m = me(o.parentPath), y =
|
|
2129
|
+
const m = me(o.parentPath), y = Mt({
|
|
2127
2130
|
tree: d.tree,
|
|
2128
2131
|
request: {
|
|
2129
2132
|
parentNodeId: m,
|
|
@@ -2135,8 +2138,8 @@ async function ls(t, r, s) {
|
|
|
2135
2138
|
maxTokensGroup: u
|
|
2136
2139
|
}
|
|
2137
2140
|
},
|
|
2138
|
-
indexRangeGroupStrategy: new
|
|
2139
|
-
}), w =
|
|
2141
|
+
indexRangeGroupStrategy: new ds()
|
|
2142
|
+
}), w = Tt(y);
|
|
2140
2143
|
return {
|
|
2141
2144
|
fsSnapshot: d,
|
|
2142
2145
|
queryCreated: p,
|
|
@@ -2151,16 +2154,16 @@ async function ls(t, r, s) {
|
|
|
2151
2154
|
};
|
|
2152
2155
|
}
|
|
2153
2156
|
}
|
|
2154
|
-
function
|
|
2155
|
-
|
|
2157
|
+
function ps(r, t) {
|
|
2158
|
+
r(
|
|
2156
2159
|
"fs-snapshot-browse",
|
|
2157
2160
|
{
|
|
2158
2161
|
title: "Browse Filesystem Snapshot",
|
|
2159
2162
|
description: "Browse and explore filesystem. Use this to efficiently browse, analyze, explore, inspect, etc directory and file structures",
|
|
2160
|
-
inputSchema:
|
|
2163
|
+
inputSchema: Ct.shape
|
|
2161
2164
|
},
|
|
2162
2165
|
async (s, o) => {
|
|
2163
|
-
const e = await
|
|
2166
|
+
const e = await fs(s, t, o);
|
|
2164
2167
|
if (e.error != null)
|
|
2165
2168
|
return `Method: fs-snapshot-browse(${JSON.stringify(s)})
|
|
2166
2169
|
❌ Error: ${e.error}`;
|
|
@@ -2182,26 +2185,26 @@ ${e.report}`, n;
|
|
|
2182
2185
|
}
|
|
2183
2186
|
);
|
|
2184
2187
|
}
|
|
2185
|
-
function
|
|
2186
|
-
const
|
|
2188
|
+
function vt(r) {
|
|
2189
|
+
const t = [], s = r.tree, o = r.query.rootDir ?? ".";
|
|
2187
2190
|
function e(n) {
|
|
2188
|
-
n.type === "file" && n.isMatched &&
|
|
2191
|
+
n.type === "file" && n.isMatched && t.push(o + "/" + n.path);
|
|
2189
2192
|
const i = s.getChilds(n);
|
|
2190
2193
|
if (i != null)
|
|
2191
2194
|
for (let a = 0; a < i.length; a++)
|
|
2192
2195
|
e(i[a]);
|
|
2193
2196
|
}
|
|
2194
|
-
return e(s.root),
|
|
2197
|
+
return e(s.root), t;
|
|
2195
2198
|
}
|
|
2196
|
-
const
|
|
2197
|
-
function
|
|
2198
|
-
const
|
|
2199
|
-
let s =
|
|
2200
|
-
return s == null && (s = new
|
|
2199
|
+
const We = /* @__PURE__ */ new Map();
|
|
2200
|
+
function hs(r) {
|
|
2201
|
+
const t = H(r);
|
|
2202
|
+
let s = We.get(t);
|
|
2203
|
+
return s == null && (s = new Xt(), We.set(t, s)), s;
|
|
2201
2204
|
}
|
|
2202
|
-
async function
|
|
2203
|
-
const { filePath:
|
|
2204
|
-
return
|
|
2205
|
+
async function ms(r) {
|
|
2206
|
+
const { filePath: t, func: s } = r;
|
|
2207
|
+
return hs(t).lock(
|
|
2205
2208
|
() => V({
|
|
2206
2209
|
pool: be,
|
|
2207
2210
|
count: 1,
|
|
@@ -2209,11 +2212,11 @@ async function ds(t) {
|
|
|
2209
2212
|
})
|
|
2210
2213
|
);
|
|
2211
2214
|
}
|
|
2212
|
-
const
|
|
2213
|
-
function
|
|
2214
|
-
const { content:
|
|
2215
|
+
const He = 10, re = 48, Qe = 57, de = 36, gs = 38, ws = 39, ys = 60, bs = 62, Ss = 96, se = 0, Ye = 1, Ve = 2, Ze = 3, Xe = 4, xs = 5;
|
|
2216
|
+
function $s(r) {
|
|
2217
|
+
const { content: t, pattern: s, replacement: o } = r, e = t.length, n = [0];
|
|
2215
2218
|
for (let b = 0; b < e; b++)
|
|
2216
|
-
|
|
2219
|
+
t.charCodeAt(b) === He && b + 1 < e && n.push(b + 1);
|
|
2217
2220
|
const i = n.length, a = [], c = [];
|
|
2218
2221
|
let l = null, u = null, f = null, d = 0;
|
|
2219
2222
|
if (o != null) {
|
|
@@ -2233,30 +2236,30 @@ function ys(t) {
|
|
|
2233
2236
|
continue;
|
|
2234
2237
|
}
|
|
2235
2238
|
const T = o.charCodeAt(x + 1);
|
|
2236
|
-
let v = -1, B = 0,
|
|
2239
|
+
let v = -1, B = 0, O = 2;
|
|
2237
2240
|
if (T === de)
|
|
2238
2241
|
v = se, B = "$";
|
|
2239
|
-
else if (T === fs)
|
|
2240
|
-
v = Qe;
|
|
2241
2242
|
else if (T === gs)
|
|
2242
2243
|
v = Ye;
|
|
2243
|
-
else if (T ===
|
|
2244
|
+
else if (T === Ss)
|
|
2244
2245
|
v = Ve;
|
|
2245
|
-
else if (T
|
|
2246
|
+
else if (T === ws)
|
|
2247
|
+
v = Ze;
|
|
2248
|
+
else if (T >= re && T <= Qe) {
|
|
2246
2249
|
let I = x + 2;
|
|
2247
2250
|
for (; I < b; ) {
|
|
2248
2251
|
const C = o.charCodeAt(I);
|
|
2249
|
-
if (C < re || C >
|
|
2252
|
+
if (C < re || C > Qe) break;
|
|
2250
2253
|
I++;
|
|
2251
2254
|
}
|
|
2252
|
-
v =
|
|
2253
|
-
} else if (T ===
|
|
2255
|
+
v = Xe, B = o.substring(x + 1, I), O = I - x;
|
|
2256
|
+
} else if (T === ys) {
|
|
2254
2257
|
let I = x + 2;
|
|
2255
|
-
for (; I < b && o.charCodeAt(I) !==
|
|
2258
|
+
for (; I < b && o.charCodeAt(I) !== bs; )
|
|
2256
2259
|
I++;
|
|
2257
|
-
I < b && I > x + 2 && (v =
|
|
2260
|
+
I < b && I > x + 2 && (v = xs, B = o.substring(x + 2, I), O = I + 1 - x);
|
|
2258
2261
|
}
|
|
2259
|
-
v >= 0 ? (x > S && (u.push(se), f.push(o.substring(S, x))), u.push(v), f.push(B), x +=
|
|
2262
|
+
v >= 0 ? (x > S && (u.push(se), f.push(o.substring(S, x))), u.push(v), f.push(B), x += O, S = x) : x++;
|
|
2260
2263
|
}
|
|
2261
2264
|
S < b && (u.push(se), f.push(o.substring(S))), d = u.length;
|
|
2262
2265
|
} else
|
|
@@ -2265,11 +2268,11 @@ function ys(t) {
|
|
|
2265
2268
|
let p = "", g = 0, m = 0;
|
|
2266
2269
|
s.lastIndex = 0;
|
|
2267
2270
|
let y;
|
|
2268
|
-
for (; (y = s.exec(
|
|
2271
|
+
for (; (y = s.exec(t)) !== null; ) {
|
|
2269
2272
|
const b = y.index, $ = y[0], S = $.length, x = b + S;
|
|
2270
|
-
let T, v, B,
|
|
2273
|
+
let T, v, B, O;
|
|
2271
2274
|
if (i === 1)
|
|
2272
|
-
T = 0, v = 1, B = 0,
|
|
2275
|
+
T = 0, v = 1, B = 0, O = e;
|
|
2273
2276
|
else {
|
|
2274
2277
|
let I = 0, C = i - 1;
|
|
2275
2278
|
for (; I < C; ) {
|
|
@@ -2279,51 +2282,51 @@ function ys(t) {
|
|
|
2279
2282
|
if (T = I, S > 0) {
|
|
2280
2283
|
const N = x - 1;
|
|
2281
2284
|
for (C = i - 1; I < C; ) {
|
|
2282
|
-
const
|
|
2283
|
-
n[
|
|
2285
|
+
const D = I + C + 1 >> 1;
|
|
2286
|
+
n[D] <= N ? I = D : C = D - 1;
|
|
2284
2287
|
}
|
|
2285
2288
|
v = I + 1;
|
|
2286
2289
|
} else
|
|
2287
2290
|
v = T + 1;
|
|
2288
|
-
B = n[T],
|
|
2291
|
+
B = n[T], O = v < i ? n[v] : e;
|
|
2289
2292
|
}
|
|
2290
2293
|
if (a.push({
|
|
2291
2294
|
offset: [b, x],
|
|
2292
2295
|
lines: [T, v],
|
|
2293
|
-
linesOffset: [B,
|
|
2296
|
+
linesOffset: [B, O]
|
|
2294
2297
|
}), o != null) {
|
|
2295
|
-
p +=
|
|
2298
|
+
p += t.substring(g, b);
|
|
2296
2299
|
let I;
|
|
2297
2300
|
if (l != null)
|
|
2298
2301
|
I = l;
|
|
2299
2302
|
else {
|
|
2300
2303
|
I = "";
|
|
2301
|
-
const N = y.groups,
|
|
2304
|
+
const N = y.groups, D = y.length - 1;
|
|
2302
2305
|
for (let W = 0; W < d; W++) {
|
|
2303
2306
|
const q = u[W], P = f[W];
|
|
2304
2307
|
switch (q) {
|
|
2305
2308
|
case se:
|
|
2306
2309
|
I += P;
|
|
2307
2310
|
break;
|
|
2308
|
-
case Qe:
|
|
2309
|
-
I += $;
|
|
2310
|
-
break;
|
|
2311
2311
|
case Ye:
|
|
2312
|
-
I +=
|
|
2312
|
+
I += $;
|
|
2313
2313
|
break;
|
|
2314
2314
|
case Ve:
|
|
2315
|
-
I +=
|
|
2315
|
+
I += t.substring(0, b);
|
|
2316
|
+
break;
|
|
2317
|
+
case Ze:
|
|
2318
|
+
I += t.substring(x);
|
|
2316
2319
|
break;
|
|
2317
|
-
case
|
|
2320
|
+
case Xe: {
|
|
2318
2321
|
const L = P, z = L.length, A = L.charCodeAt(0) - re;
|
|
2319
2322
|
if (z >= 2) {
|
|
2320
|
-
const G = L.charCodeAt(1) - re,
|
|
2321
|
-
if (
|
|
2322
|
-
I += y[
|
|
2323
|
+
const G = L.charCodeAt(1) - re, R = A * 10 + G;
|
|
2324
|
+
if (R >= 1 && R <= D) {
|
|
2325
|
+
I += y[R] ?? "", z > 2 && (I += L.substring(2));
|
|
2323
2326
|
break;
|
|
2324
2327
|
}
|
|
2325
2328
|
}
|
|
2326
|
-
A >= 1 && A <=
|
|
2329
|
+
A >= 1 && A <= D ? (I += y[A] ?? "", z > 1 && (I += L.substring(1))) : I += "$" + L;
|
|
2327
2330
|
break;
|
|
2328
2331
|
}
|
|
2329
2332
|
default:
|
|
@@ -2343,54 +2346,54 @@ function ys(t) {
|
|
|
2343
2346
|
break;
|
|
2344
2347
|
}
|
|
2345
2348
|
if (s.lastIndex = 0, o == null)
|
|
2346
|
-
return { search: { content:
|
|
2347
|
-
p +=
|
|
2349
|
+
return { search: { content: t, matches: a }, replace: null };
|
|
2350
|
+
p += t.substring(g);
|
|
2348
2351
|
const w = p.length, M = [0];
|
|
2349
2352
|
for (let b = 0; b < w; b++)
|
|
2350
|
-
p.charCodeAt(b) ===
|
|
2353
|
+
p.charCodeAt(b) === He && b + 1 < w && M.push(b + 1);
|
|
2351
2354
|
const E = M.length;
|
|
2352
2355
|
for (let b = 0, $ = c.length; b < $; b++) {
|
|
2353
2356
|
const S = c[b], x = S.offset[0], T = S.offset[1];
|
|
2354
|
-
let v, B,
|
|
2357
|
+
let v, B, O, I;
|
|
2355
2358
|
if (E === 1)
|
|
2356
|
-
v = 0, B = 1,
|
|
2359
|
+
v = 0, B = 1, O = 0, I = w;
|
|
2357
2360
|
else {
|
|
2358
2361
|
let C = 0, N = E - 1;
|
|
2359
2362
|
for (; C < N; ) {
|
|
2360
|
-
const
|
|
2361
|
-
M[
|
|
2363
|
+
const D = C + N + 1 >> 1;
|
|
2364
|
+
M[D] <= x ? C = D : N = D - 1;
|
|
2362
2365
|
}
|
|
2363
2366
|
if (v = C, T > x) {
|
|
2364
|
-
const
|
|
2367
|
+
const D = T - 1;
|
|
2365
2368
|
for (N = E - 1; C < N; ) {
|
|
2366
2369
|
const W = C + N + 1 >> 1;
|
|
2367
|
-
M[W] <=
|
|
2370
|
+
M[W] <= D ? C = W : N = W - 1;
|
|
2368
2371
|
}
|
|
2369
2372
|
B = C + 1;
|
|
2370
2373
|
} else
|
|
2371
2374
|
B = v + 1;
|
|
2372
|
-
|
|
2375
|
+
O = M[v], I = B < E ? M[B] : w;
|
|
2373
2376
|
}
|
|
2374
|
-
S.lines[0] = v, S.lines[1] = B, S.linesOffset[0] =
|
|
2377
|
+
S.lines[0] = v, S.lines[1] = B, S.linesOffset[0] = O, S.linesOffset[1] = I;
|
|
2375
2378
|
}
|
|
2376
2379
|
return {
|
|
2377
|
-
search: { content:
|
|
2380
|
+
search: { content: t, matches: a },
|
|
2378
2381
|
replace: { content: p, matches: c }
|
|
2379
2382
|
};
|
|
2380
2383
|
}
|
|
2381
|
-
function
|
|
2382
|
-
if (
|
|
2384
|
+
function Et(r) {
|
|
2385
|
+
if (r.length === 0)
|
|
2383
2386
|
return [];
|
|
2384
|
-
const
|
|
2387
|
+
const t = [...r].sort((i, a) => {
|
|
2385
2388
|
const c = i.lines[0], l = a.lines[0];
|
|
2386
2389
|
if (c > l) return 1;
|
|
2387
2390
|
if (c < l) return -1;
|
|
2388
2391
|
const u = i.lines[1], f = a.lines[1];
|
|
2389
2392
|
return u > f ? 1 : u < f ? -1 : 0;
|
|
2390
2393
|
}), s = [];
|
|
2391
|
-
let o = [...
|
|
2392
|
-
for (let i = 1; i <
|
|
2393
|
-
const a =
|
|
2394
|
+
let o = [...t[0].offset], e = [...t[0].lines], n = [...t[0].linesOffset];
|
|
2395
|
+
for (let i = 1; i < t.length; i++) {
|
|
2396
|
+
const a = t[i];
|
|
2394
2397
|
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({
|
|
2395
2398
|
offset: o,
|
|
2396
2399
|
lines: e,
|
|
@@ -2403,33 +2406,33 @@ function Ct(t) {
|
|
|
2403
2406
|
linesOffset: n
|
|
2404
2407
|
}), s;
|
|
2405
2408
|
}
|
|
2406
|
-
function oe(
|
|
2409
|
+
function oe(r, t, s, o) {
|
|
2407
2410
|
let e = 0, n = 0;
|
|
2408
2411
|
for (let u = 0; u < s; u++)
|
|
2409
|
-
|
|
2412
|
+
r.charCodeAt(u) === 10 && (n = u + 1, e++);
|
|
2410
2413
|
const i = e, a = n;
|
|
2411
2414
|
let c = s;
|
|
2412
2415
|
for (; c < o; c++)
|
|
2413
|
-
|
|
2416
|
+
r.charCodeAt(c) === 10 && e++;
|
|
2414
2417
|
const l = e + 1;
|
|
2415
|
-
for (; c <
|
|
2416
|
-
if (
|
|
2418
|
+
for (; c < t; c++)
|
|
2419
|
+
if (r.charCodeAt(c) === 10)
|
|
2417
2420
|
return { startLine: i, endLine: l, startLineOfs: a, endLineOfs: c + 1 };
|
|
2418
|
-
return { startLine: i, endLine: l, startLineOfs: a, endLineOfs:
|
|
2421
|
+
return { startLine: i, endLine: l, startLineOfs: a, endLineOfs: t };
|
|
2419
2422
|
}
|
|
2420
|
-
function
|
|
2421
|
-
if (
|
|
2422
|
-
const U = [...
|
|
2423
|
+
function Is(r, t) {
|
|
2424
|
+
if (r.replace == null && t.replace == null) {
|
|
2425
|
+
const U = [...r.search.matches, ...t.search.matches];
|
|
2423
2426
|
return {
|
|
2424
|
-
search: { content:
|
|
2427
|
+
search: { content: r.search.content, matches: Et(U) },
|
|
2425
2428
|
replace: null
|
|
2426
2429
|
};
|
|
2427
2430
|
}
|
|
2428
|
-
const s =
|
|
2429
|
-
let y = 0, w = 0, M = 0, E = 0, b = 0, $ = 0, S = 0, x = 0, T = 0, v = 0, B = 0,
|
|
2431
|
+
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, g = [], m = [];
|
|
2432
|
+
let y = 0, w = 0, M = 0, E = 0, b = 0, $ = 0, S = 0, x = 0, T = 0, v = 0, B = 0, O = 0, I = 0, C = 0, N = 0, D = 0, W = 0, q = 0, P = 0, L = 0, z = 0, A = 0, G = 0, R = 0;
|
|
2430
2433
|
for (; y < d || w < p; )
|
|
2431
2434
|
if (y < d && (b = l[y].offset[0], $ = l[y].offset[1]), w < p && (S = u[w].offset[0], x = u[w].offset[1]), y < d && w < p && b < x && S < $) {
|
|
2432
|
-
W = b < S ? b : S, T = $ > x ? $ : x, B = y,
|
|
2435
|
+
W = b < S ? b : S, T = $ > x ? $ : x, B = y, O = w, y++, w++;
|
|
2433
2436
|
do {
|
|
2434
2437
|
for (v = T; y < d && l[y].offset[0] < T; )
|
|
2435
2438
|
$ = l[y].offset[1], $ > T && (T = $), y++;
|
|
@@ -2438,28 +2441,28 @@ function bs(t, r) {
|
|
|
2438
2441
|
} while (T !== v);
|
|
2439
2442
|
I = 1 / 0, C = -1 / 0, q = W, P = M;
|
|
2440
2443
|
for (let _ = B; _ < y; _++)
|
|
2441
|
-
L = c[_].offset[0], z = c[_].offset[1], A = l[_].offset[0], G = l[_].offset[1], q < A && (
|
|
2442
|
-
q < T && (
|
|
2443
|
-
for (let _ =
|
|
2444
|
-
L = u[_].offset[0], z = u[_].offset[1], A = f[_].offset[0], G = f[_].offset[1], q < L && (
|
|
2445
|
-
q < T && (
|
|
2444
|
+
L = c[_].offset[0], z = c[_].offset[1], A = l[_].offset[0], G = l[_].offset[1], q < A && (R = q + P, R < I && (I = R), R = A + P, R > C && (C = R)), L < I && (I = L), z > C && (C = z), P += z - L - G + A, q = G;
|
|
2445
|
+
q < T && (R = q + P, R < I && (I = R), R = T + P, R > C && (C = R)), M = P, N = 1 / 0, D = -1 / 0, q = W, P = E;
|
|
2446
|
+
for (let _ = O; _ < w; _++)
|
|
2447
|
+
L = u[_].offset[0], z = u[_].offset[1], A = f[_].offset[0], G = f[_].offset[1], q < L && (R = q + P, R < N && (N = R), R = L + P, R > D && (D = R)), A < N && (N = A), G > D && (D = G), P += G - A - z + L, q = z;
|
|
2448
|
+
q < T && (R = q + P, R < N && (N = R), R = T + P, R > D && (D = R)), E = P;
|
|
2446
2449
|
const U = oe(e, i, I, C);
|
|
2447
2450
|
g.push({
|
|
2448
2451
|
offset: [I, C],
|
|
2449
2452
|
lines: [U.startLine, U.endLine],
|
|
2450
2453
|
linesOffset: [U.startLineOfs, U.endLineOfs]
|
|
2451
2454
|
});
|
|
2452
|
-
const te = oe(n, a, N,
|
|
2455
|
+
const te = oe(n, a, N, D);
|
|
2453
2456
|
m.push({
|
|
2454
|
-
offset: [N,
|
|
2457
|
+
offset: [N, D],
|
|
2455
2458
|
lines: [te.startLine, te.endLine],
|
|
2456
2459
|
linesOffset: [te.startLineOfs, te.endLineOfs]
|
|
2457
2460
|
});
|
|
2458
2461
|
} else if (w >= p || y < d && b <= S) {
|
|
2459
|
-
L = c[y].offset[0], z = c[y].offset[1], A = l[y].offset[0], G = l[y].offset[1], N = A + E,
|
|
2460
|
-
const U = oe(n, a, N,
|
|
2462
|
+
L = c[y].offset[0], z = c[y].offset[1], A = l[y].offset[0], G = l[y].offset[1], N = A + E, D = G + E;
|
|
2463
|
+
const U = oe(n, a, N, D);
|
|
2461
2464
|
g.push(c[y]), m.push({
|
|
2462
|
-
offset: [N,
|
|
2465
|
+
offset: [N, D],
|
|
2463
2466
|
lines: [U.startLine, U.endLine],
|
|
2464
2467
|
linesOffset: [U.startLineOfs, U.endLineOfs]
|
|
2465
2468
|
}), M += z - L - G + A, y++;
|
|
@@ -2477,17 +2480,17 @@ function bs(t, r) {
|
|
|
2477
2480
|
replace: { content: n, matches: m }
|
|
2478
2481
|
};
|
|
2479
2482
|
}
|
|
2480
|
-
async function
|
|
2481
|
-
const { filePath:
|
|
2482
|
-
return s.length === 0 ? { filePath:
|
|
2483
|
-
filePath:
|
|
2483
|
+
async function Ms(r) {
|
|
2484
|
+
const { filePath: t, operations: s, dryRun: o } = r;
|
|
2485
|
+
return s.length === 0 ? { filePath: t, result: null } : ms({
|
|
2486
|
+
filePath: t,
|
|
2484
2487
|
func: async () => {
|
|
2485
2488
|
let e;
|
|
2486
2489
|
try {
|
|
2487
|
-
e = await
|
|
2490
|
+
e = await j.promises.readFile(t, "utf-8");
|
|
2488
2491
|
} catch (a) {
|
|
2489
2492
|
return {
|
|
2490
|
-
filePath:
|
|
2493
|
+
filePath: t,
|
|
2491
2494
|
result: null,
|
|
2492
2495
|
error: `Failed to read file: ${a instanceof Error ? a.message : a + ""}`
|
|
2493
2496
|
};
|
|
@@ -2500,41 +2503,41 @@ async function Ss(t) {
|
|
|
2500
2503
|
l = new RegExp(c.pattern, c.flags ?? "");
|
|
2501
2504
|
} catch (d) {
|
|
2502
2505
|
return {
|
|
2503
|
-
filePath:
|
|
2506
|
+
filePath: t,
|
|
2504
2507
|
result: null,
|
|
2505
2508
|
error: `Invalid RegExp pattern "${c.pattern}": ${d instanceof Error ? d.message : d + ""}`
|
|
2506
2509
|
};
|
|
2507
2510
|
}
|
|
2508
|
-
const u = n?.replace?.content ?? e, f =
|
|
2511
|
+
const u = n?.replace?.content ?? e, f = $s({
|
|
2509
2512
|
content: u,
|
|
2510
2513
|
pattern: l,
|
|
2511
2514
|
replacement: c.replacement
|
|
2512
2515
|
});
|
|
2513
|
-
c.replacement != null && (i = !0), n == null ? n = f : n =
|
|
2516
|
+
c.replacement != null && (i = !0), n == null ? n = f : n = Is(n, f);
|
|
2514
2517
|
}
|
|
2515
2518
|
if (i && n?.replace != null && !o) {
|
|
2516
2519
|
const a = n.replace.content;
|
|
2517
2520
|
if (a !== e)
|
|
2518
2521
|
try {
|
|
2519
|
-
await
|
|
2522
|
+
await j.promises.writeFile(t, a, "utf-8");
|
|
2520
2523
|
} catch (c) {
|
|
2521
2524
|
return {
|
|
2522
|
-
filePath:
|
|
2525
|
+
filePath: t,
|
|
2523
2526
|
result: n,
|
|
2524
2527
|
error: `Failed to write file: ${c instanceof Error ? c.message : c + ""}`
|
|
2525
2528
|
};
|
|
2526
2529
|
}
|
|
2527
2530
|
}
|
|
2528
|
-
return { filePath:
|
|
2531
|
+
return { filePath: t, result: n };
|
|
2529
2532
|
}
|
|
2530
2533
|
});
|
|
2531
2534
|
}
|
|
2532
|
-
async function xe(
|
|
2533
|
-
const { filePaths:
|
|
2535
|
+
async function xe(r) {
|
|
2536
|
+
const { filePaths: t, operations: s, dryRun: o, dateModifiedMax: e } = r;
|
|
2534
2537
|
return { results: await Promise.all(
|
|
2535
|
-
|
|
2538
|
+
t.map(async (i) => {
|
|
2536
2539
|
if (e != null) {
|
|
2537
|
-
const a = await
|
|
2540
|
+
const a = await j.promises.stat(i).catch(() => null);
|
|
2538
2541
|
if (a == null)
|
|
2539
2542
|
return {
|
|
2540
2543
|
filePath: i,
|
|
@@ -2548,34 +2551,34 @@ async function xe(t) {
|
|
|
2548
2551
|
error: "Not replaced, try again"
|
|
2549
2552
|
};
|
|
2550
2553
|
}
|
|
2551
|
-
return
|
|
2554
|
+
return Ms({ filePath: i, operations: s, dryRun: o });
|
|
2552
2555
|
})
|
|
2553
2556
|
) };
|
|
2554
2557
|
}
|
|
2555
|
-
const
|
|
2556
|
-
function
|
|
2557
|
-
const { content:
|
|
2558
|
+
const Ts = 6;
|
|
2559
|
+
function Cs(r) {
|
|
2560
|
+
const { content: t, startLine: s } = r, o = r.padWidth ?? Ts;
|
|
2558
2561
|
let e = "", n = 0, i = 0;
|
|
2559
|
-
for (; n <
|
|
2560
|
-
const a =
|
|
2561
|
-
`, n), c = a === -1 ?
|
|
2562
|
-
e += String(s + i + 1).padStart(o) + "→" +
|
|
2562
|
+
for (; n < t.length; ) {
|
|
2563
|
+
const a = t.indexOf(`
|
|
2564
|
+
`, n), c = a === -1 ? t.length : a + 1;
|
|
2565
|
+
e += String(s + i + 1).padStart(o) + "→" + t.substring(n, c), n = c, i++;
|
|
2563
2566
|
}
|
|
2564
2567
|
return e.length > 0 && !e.endsWith(`
|
|
2565
2568
|
`) && (e += `
|
|
2566
2569
|
`), e;
|
|
2567
2570
|
}
|
|
2568
|
-
function fe(
|
|
2569
|
-
const { content:
|
|
2571
|
+
function fe(r) {
|
|
2572
|
+
const { content: t, matches: s, outputLimit: o } = r;
|
|
2570
2573
|
if (s.length === 0)
|
|
2571
2574
|
return { output: "", truncated: !1 };
|
|
2572
|
-
const e =
|
|
2575
|
+
const e = Et(s);
|
|
2573
2576
|
let n = "", i = !1;
|
|
2574
2577
|
for (let a = 0; a < e.length; a++) {
|
|
2575
|
-
const c = e[a], l =
|
|
2578
|
+
const c = e[a], l = t.substring(
|
|
2576
2579
|
c.linesOffset[0],
|
|
2577
2580
|
c.linesOffset[1]
|
|
2578
|
-
), u =
|
|
2581
|
+
), u = Cs({
|
|
2579
2582
|
content: l,
|
|
2580
2583
|
startLine: c.lines[0]
|
|
2581
2584
|
}), f = a > 0 ? 2 : 0;
|
|
@@ -2588,40 +2591,40 @@ function fe(t) {
|
|
|
2588
2591
|
}
|
|
2589
2592
|
return { output: n, truncated: i };
|
|
2590
2593
|
}
|
|
2591
|
-
const
|
|
2592
|
-
function
|
|
2593
|
-
const { result:
|
|
2594
|
-
if (
|
|
2594
|
+
const et = "BEFORE", tt = "AFTER";
|
|
2595
|
+
function vs(r) {
|
|
2596
|
+
const { result: t, outputLimit: s } = r;
|
|
2597
|
+
if (t.replace == null) {
|
|
2595
2598
|
const g = fe({
|
|
2596
|
-
content:
|
|
2597
|
-
matches:
|
|
2599
|
+
content: t.search.content,
|
|
2600
|
+
matches: t.search.matches,
|
|
2598
2601
|
outputLimit: s
|
|
2599
2602
|
});
|
|
2600
2603
|
return { output: g.output, truncated: g.truncated };
|
|
2601
2604
|
}
|
|
2602
|
-
const o = `<${
|
|
2603
|
-
`, e = `</${
|
|
2604
|
-
`, n = `<${
|
|
2605
|
-
`, i = `</${
|
|
2605
|
+
const o = `<${et}>
|
|
2606
|
+
`, e = `</${et}>
|
|
2607
|
+
`, n = `<${tt}>
|
|
2608
|
+
`, i = `</${tt}>
|
|
2606
2609
|
`, a = o.length + e.length + n.length + i.length;
|
|
2607
2610
|
if (s != null && s < a)
|
|
2608
2611
|
return { output: "", truncated: !0 };
|
|
2609
2612
|
const c = s != null ? s - a : void 0, l = c != null ? Math.floor(c / 2) : void 0, u = fe({
|
|
2610
|
-
content:
|
|
2611
|
-
matches:
|
|
2613
|
+
content: t.search.content,
|
|
2614
|
+
matches: t.search.matches,
|
|
2612
2615
|
outputLimit: l
|
|
2613
2616
|
}), f = c != null ? c - u.output.length : void 0, d = fe({
|
|
2614
|
-
content:
|
|
2615
|
-
matches:
|
|
2617
|
+
content: t.replace.content,
|
|
2618
|
+
matches: t.replace.matches,
|
|
2616
2619
|
outputLimit: f
|
|
2617
2620
|
});
|
|
2618
2621
|
return { output: o + u.output + e + n + d.output + i, truncated: u.truncated || d.truncated };
|
|
2619
2622
|
}
|
|
2620
|
-
function $e(
|
|
2621
|
-
const { result:
|
|
2623
|
+
function $e(r) {
|
|
2624
|
+
const { result: t, rootDir: s, errorsOnly: o } = r;
|
|
2622
2625
|
let e = "";
|
|
2623
|
-
for (let n = 0; n <
|
|
2624
|
-
const i =
|
|
2626
|
+
for (let n = 0; n < t.results.length; n++) {
|
|
2627
|
+
const i = t.results[n], a = k.relative(s, i.filePath), c = e.length > 0 ? 1 : 0;
|
|
2625
2628
|
if (i.error != null) {
|
|
2626
2629
|
const u = a + `
|
|
2627
2630
|
❌ ` + i.error + `
|
|
@@ -2632,7 +2635,7 @@ function $e(t) {
|
|
|
2632
2635
|
}
|
|
2633
2636
|
if (o || i.result == null || i.result.search.matches.length === 0)
|
|
2634
2637
|
continue;
|
|
2635
|
-
const l =
|
|
2638
|
+
const l = vs({
|
|
2636
2639
|
result: i.result
|
|
2637
2640
|
});
|
|
2638
2641
|
l.output.length > 0 && (c > 0 && (e += `
|
|
@@ -2641,25 +2644,25 @@ function $e(t) {
|
|
|
2641
2644
|
}
|
|
2642
2645
|
return e;
|
|
2643
2646
|
}
|
|
2644
|
-
const
|
|
2647
|
+
const Es = h.object({
|
|
2645
2648
|
pattern: h.string().describe("JS RegExp pattern"),
|
|
2646
2649
|
flags: h.string().default("gm").describe('JS RegExp flags. Default: "gm"')
|
|
2647
|
-
}),
|
|
2650
|
+
}), Nt = h.object({
|
|
2648
2651
|
snapshotName: h.string().optional().describe("Name of previously created filesystem snapshot, to use"),
|
|
2649
2652
|
snapshot: ee.optional().describe(
|
|
2650
2653
|
"Filesystem snapshot creation options JSON to automatically create snapshot"
|
|
2651
2654
|
),
|
|
2652
|
-
bulkOperations: h.array(
|
|
2655
|
+
bulkOperations: h.array(Es).describe(
|
|
2653
2656
|
"All search patterns to execute; include every pattern here; never split across multiple calls"
|
|
2654
2657
|
),
|
|
2655
|
-
outputLimit: h.number().int().min(0).max(
|
|
2656
|
-
`Maximum output characters. Output exceeding this limit will be truncated. Maximum: ${
|
|
2658
|
+
outputLimit: h.number().int().min(0).max(J).default(Q).describe(
|
|
2659
|
+
`Maximum output characters. Output exceeding this limit will be truncated. Maximum: ${J}. Default: ${Q}`
|
|
2657
2660
|
)
|
|
2658
2661
|
});
|
|
2659
|
-
async function
|
|
2662
|
+
async function Ns(r, t, s) {
|
|
2660
2663
|
let o;
|
|
2661
2664
|
try {
|
|
2662
|
-
o =
|
|
2665
|
+
o = Nt.parse(r);
|
|
2663
2666
|
} catch (w) {
|
|
2664
2667
|
return {
|
|
2665
2668
|
error: F(w)
|
|
@@ -2684,7 +2687,7 @@ async function Ts(t, r, s) {
|
|
|
2684
2687
|
} else if (n) {
|
|
2685
2688
|
const w = await ce(
|
|
2686
2689
|
n,
|
|
2687
|
-
|
|
2690
|
+
t,
|
|
2688
2691
|
s
|
|
2689
2692
|
);
|
|
2690
2693
|
if (w.error != null)
|
|
@@ -2696,7 +2699,7 @@ async function Ts(t, r, s) {
|
|
|
2696
2699
|
return {
|
|
2697
2700
|
error: "Either snapshotName or snapshot must be provided"
|
|
2698
2701
|
};
|
|
2699
|
-
const d =
|
|
2702
|
+
const d = vt(l), p = l.query.rootDir ?? ".", g = await xe({
|
|
2700
2703
|
filePaths: d,
|
|
2701
2704
|
operations: i
|
|
2702
2705
|
}), m = $e({
|
|
@@ -2709,18 +2712,18 @@ async function Ts(t, r, s) {
|
|
|
2709
2712
|
limit: a
|
|
2710
2713
|
}).content, rootDir: p, fsSnapshot: l, queryCreated: u, snapshotCreated: f };
|
|
2711
2714
|
}
|
|
2712
|
-
function
|
|
2713
|
-
|
|
2715
|
+
function ks(r, t) {
|
|
2716
|
+
r(
|
|
2714
2717
|
"fs-snapshot-search",
|
|
2715
2718
|
{
|
|
2716
2719
|
title: "Search File Contents in Snapshot",
|
|
2717
2720
|
description: "Search file contents using JS RegExp. Use this to find text patterns across snapshot files. Put all search patterns in the bulkOperations array; use one snapshot with rootDir covering all target files; never split into multiple calls based on file locations, directories, or pattern groups",
|
|
2718
|
-
inputSchema:
|
|
2721
|
+
inputSchema: Nt.shape
|
|
2719
2722
|
},
|
|
2720
2723
|
async (s, o) => {
|
|
2721
|
-
const e = await
|
|
2724
|
+
const e = await Ns(
|
|
2722
2725
|
s,
|
|
2723
|
-
|
|
2726
|
+
t,
|
|
2724
2727
|
o
|
|
2725
2728
|
);
|
|
2726
2729
|
if (e.error != null)
|
|
@@ -2739,26 +2742,26 @@ Reminder: use one snapshot covering all target files; include all patterns in th
|
|
|
2739
2742
|
}
|
|
2740
2743
|
);
|
|
2741
2744
|
}
|
|
2742
|
-
const
|
|
2745
|
+
const Os = h.object({
|
|
2743
2746
|
pattern: h.string().describe("JS RegExp pattern"),
|
|
2744
2747
|
flags: h.string().default("gm").describe('JS RegExp flags. Default: "gm"'),
|
|
2745
2748
|
replacement: h.string().describe("JS replacement pattern")
|
|
2746
|
-
}),
|
|
2749
|
+
}), kt = h.object({
|
|
2747
2750
|
snapshotName: h.string().optional().describe("Name of previously created filesystem snapshot, to use"),
|
|
2748
2751
|
snapshot: ee.optional().describe(
|
|
2749
2752
|
"Filesystem snapshot creation options JSON to automatically create snapshot"
|
|
2750
2753
|
),
|
|
2751
|
-
bulkOperations: h.array(
|
|
2754
|
+
bulkOperations: h.array(Os).describe(
|
|
2752
2755
|
"All replace patterns to execute; include every pattern here; never split across multiple calls"
|
|
2753
2756
|
),
|
|
2754
|
-
outputLimit: h.number().int().min(0).max(
|
|
2755
|
-
`Maximum output characters. Output exceeding this limit will be truncated. Maximum: ${
|
|
2757
|
+
outputLimit: h.number().int().min(0).max(J).default(Q).describe(
|
|
2758
|
+
`Maximum output characters. Output exceeding this limit will be truncated. Maximum: ${J}. Default: ${Q}`
|
|
2756
2759
|
)
|
|
2757
2760
|
});
|
|
2758
|
-
async function
|
|
2761
|
+
async function Ds(r, t, s) {
|
|
2759
2762
|
let o;
|
|
2760
2763
|
try {
|
|
2761
|
-
o =
|
|
2764
|
+
o = kt.parse(r);
|
|
2762
2765
|
} catch (b) {
|
|
2763
2766
|
return {
|
|
2764
2767
|
error: F(b)
|
|
@@ -2783,7 +2786,7 @@ async function Es(t, r, s) {
|
|
|
2783
2786
|
} else if (n) {
|
|
2784
2787
|
const b = await ce(
|
|
2785
2788
|
n,
|
|
2786
|
-
|
|
2789
|
+
t,
|
|
2787
2790
|
s
|
|
2788
2791
|
);
|
|
2789
2792
|
if (b.error != null)
|
|
@@ -2795,13 +2798,13 @@ async function Es(t, r, s) {
|
|
|
2795
2798
|
return {
|
|
2796
2799
|
error: "Either snapshotName or snapshot must be provided"
|
|
2797
2800
|
};
|
|
2798
|
-
const d =
|
|
2801
|
+
const d = vt(l), p = l.query.rootDir ?? ".", g = {
|
|
2799
2802
|
filePaths: d,
|
|
2800
2803
|
operations: i
|
|
2801
2804
|
}, m = Date.now(), y = await xe({
|
|
2802
2805
|
...g,
|
|
2803
2806
|
dryRun: !0
|
|
2804
|
-
}), w =
|
|
2807
|
+
}), w = Zr();
|
|
2805
2808
|
c.preparedReplace = {
|
|
2806
2809
|
id: w,
|
|
2807
2810
|
options: g,
|
|
@@ -2820,18 +2823,18 @@ Review the output carefully before executing. Call fs-snapshot-replace-execute w
|
|
|
2820
2823
|
limit: a
|
|
2821
2824
|
}).content, rootDir: p, fsSnapshot: l, queryCreated: u, snapshotCreated: f };
|
|
2822
2825
|
}
|
|
2823
|
-
function
|
|
2824
|
-
|
|
2826
|
+
function Rs(r, t) {
|
|
2827
|
+
r(
|
|
2825
2828
|
"fs-snapshot-replace-prepare",
|
|
2826
2829
|
{
|
|
2827
2830
|
title: "Prepare File Content Replacement",
|
|
2828
2831
|
description: "Prepares text replacement in files using JS RegExp. Use this to perform bulk replacements across snapshot files. Put all replace patterns in the bulkOperations array; use one snapshot with rootDir covering all target files; never split into multiple calls based on file locations, directories, or pattern groups. Read and review full output to the end. If all replacements are valid get replaceId from the end of output and call fs-snapshot-replace-execute to apply it.",
|
|
2829
|
-
inputSchema:
|
|
2832
|
+
inputSchema: kt.shape
|
|
2830
2833
|
},
|
|
2831
2834
|
async (s, o) => {
|
|
2832
|
-
const e = await
|
|
2835
|
+
const e = await Ds(
|
|
2833
2836
|
s,
|
|
2834
|
-
|
|
2837
|
+
t,
|
|
2835
2838
|
o
|
|
2836
2839
|
);
|
|
2837
2840
|
if (e.error != null)
|
|
@@ -2850,13 +2853,13 @@ Reminder: use one snapshot covering all target files; include all patterns in th
|
|
|
2850
2853
|
}
|
|
2851
2854
|
);
|
|
2852
2855
|
}
|
|
2853
|
-
const
|
|
2856
|
+
const Ot = h.object({
|
|
2854
2857
|
replaceId: h.string().describe("Replace ID from fs-snapshot-replace-prepare output")
|
|
2855
2858
|
});
|
|
2856
|
-
async function
|
|
2859
|
+
async function Fs(r, t, s) {
|
|
2857
2860
|
let o;
|
|
2858
2861
|
try {
|
|
2859
|
-
o =
|
|
2862
|
+
o = Ot.parse(r);
|
|
2860
2863
|
} catch (l) {
|
|
2861
2864
|
return {
|
|
2862
2865
|
error: F(l)
|
|
@@ -2886,18 +2889,18 @@ async function ks(t, r, s) {
|
|
|
2886
2889
|
errorsOnly: !0
|
|
2887
2890
|
}) || null };
|
|
2888
2891
|
}
|
|
2889
|
-
function
|
|
2890
|
-
|
|
2892
|
+
function Bs(r, t) {
|
|
2893
|
+
r(
|
|
2891
2894
|
"fs-snapshot-replace-execute",
|
|
2892
2895
|
{
|
|
2893
2896
|
title: "Execute Prepared Replacement",
|
|
2894
2897
|
description: "Executes prepared replacement. Requires replaceId from the end of fs-snapshot-replace-prepare output.",
|
|
2895
|
-
inputSchema:
|
|
2898
|
+
inputSchema: Ot.shape
|
|
2896
2899
|
},
|
|
2897
2900
|
async (s, o) => {
|
|
2898
|
-
const e = await
|
|
2901
|
+
const e = await Fs(
|
|
2899
2902
|
s,
|
|
2900
|
-
|
|
2903
|
+
t,
|
|
2901
2904
|
o
|
|
2902
2905
|
);
|
|
2903
2906
|
if (e.error != null)
|
|
@@ -2910,19 +2913,19 @@ ${e.output}`), n;
|
|
|
2910
2913
|
}
|
|
2911
2914
|
);
|
|
2912
2915
|
}
|
|
2913
|
-
function
|
|
2914
|
-
|
|
2916
|
+
function Ls(r, t) {
|
|
2917
|
+
t.list && Yr(r, t), t.snapshotQueryCreate && es(r, t), t.snapshotCreate && ls(r, t), t.snapshotBrowse && ps(r, t), t.snapshotSearch && ks(r, t), t.snapshotReplace && (Rs(r, t), Bs(r, t)), console.log(
|
|
2915
2918
|
`File manager:
|
|
2916
|
-
- Working directory: ${
|
|
2919
|
+
- Working directory: ${k.resolve(t.workingDir || "")}
|
|
2917
2920
|
`
|
|
2918
2921
|
);
|
|
2919
2922
|
}
|
|
2920
2923
|
const pe = /* @__PURE__ */ new Map();
|
|
2921
|
-
function K(
|
|
2922
|
-
return pe.has(
|
|
2924
|
+
function K(r) {
|
|
2925
|
+
return pe.has(r) || pe.set(r, {
|
|
2923
2926
|
browsers: /* @__PURE__ */ new Map(),
|
|
2924
2927
|
domSnapshotQueries: /* @__PURE__ */ new Map()
|
|
2925
|
-
}), pe.get(
|
|
2928
|
+
}), pe.get(r);
|
|
2926
2929
|
}
|
|
2927
2930
|
const Ie = h.object({
|
|
2928
2931
|
name: h.string().describe(
|
|
@@ -2932,10 +2935,10 @@ const Ie = h.object({
|
|
|
2932
2935
|
muteAudio: h.boolean().optional().describe("Mute audio in the browser"),
|
|
2933
2936
|
devTools: h.boolean().optional().describe("Open browser with dev tools")
|
|
2934
2937
|
});
|
|
2935
|
-
async function
|
|
2938
|
+
async function Dt(r, t, s) {
|
|
2936
2939
|
let o;
|
|
2937
2940
|
try {
|
|
2938
|
-
o = Ie.parse(
|
|
2941
|
+
o = Ie.parse(r);
|
|
2939
2942
|
} catch (l) {
|
|
2940
2943
|
return {
|
|
2941
2944
|
error: F(l)
|
|
@@ -2949,9 +2952,9 @@ async function kt(t, r, s) {
|
|
|
2949
2952
|
const c = K(s.sessionId);
|
|
2950
2953
|
try {
|
|
2951
2954
|
const u = await {
|
|
2952
|
-
chromium:
|
|
2953
|
-
firefox:
|
|
2954
|
-
webkit:
|
|
2955
|
+
chromium: or,
|
|
2956
|
+
firefox: sr,
|
|
2957
|
+
webkit: rr
|
|
2955
2958
|
}[n].launch({
|
|
2956
2959
|
headless: !1,
|
|
2957
2960
|
devtools: a,
|
|
@@ -2969,8 +2972,8 @@ async function kt(t, r, s) {
|
|
|
2969
2972
|
};
|
|
2970
2973
|
}
|
|
2971
2974
|
}
|
|
2972
|
-
function
|
|
2973
|
-
|
|
2975
|
+
function Ps(r, t) {
|
|
2976
|
+
r(
|
|
2974
2977
|
"playwright-browser-create",
|
|
2975
2978
|
{
|
|
2976
2979
|
title: "Create Browser",
|
|
@@ -2978,17 +2981,17 @@ function Rs(t, r) {
|
|
|
2978
2981
|
inputSchema: Ie.shape
|
|
2979
2982
|
},
|
|
2980
2983
|
async (s, o) => {
|
|
2981
|
-
const e = await
|
|
2984
|
+
const e = await Dt(s, t, o);
|
|
2982
2985
|
return `Method: playwright-browser-create(${JSON.stringify(s)})
|
|
2983
2986
|
${e.error != null ? `❌ Error: ${e.error}` : `✅ Browser "${e.browserInfo.name}" (${e.browserInfo.browserType}) created successfully`}`;
|
|
2984
2987
|
}
|
|
2985
2988
|
);
|
|
2986
2989
|
}
|
|
2987
|
-
const
|
|
2988
|
-
async function
|
|
2990
|
+
const Rt = h.object({});
|
|
2991
|
+
async function As(r, t, s) {
|
|
2989
2992
|
let o;
|
|
2990
2993
|
try {
|
|
2991
|
-
o =
|
|
2994
|
+
o = Rt.parse(r);
|
|
2992
2995
|
} catch (i) {
|
|
2993
2996
|
return {
|
|
2994
2997
|
error: F(i)
|
|
@@ -3003,16 +3006,16 @@ async function Fs(t, r, s) {
|
|
|
3003
3006
|
browserInfos: Array.from(e.browsers.values())
|
|
3004
3007
|
};
|
|
3005
3008
|
}
|
|
3006
|
-
function
|
|
3007
|
-
|
|
3009
|
+
function zs(r, t) {
|
|
3010
|
+
r(
|
|
3008
3011
|
"playwright-browser-list",
|
|
3009
3012
|
{
|
|
3010
3013
|
title: "List Browsers",
|
|
3011
3014
|
description: "List active browser instances",
|
|
3012
|
-
inputSchema:
|
|
3015
|
+
inputSchema: Rt.shape
|
|
3013
3016
|
},
|
|
3014
3017
|
async (s, o) => {
|
|
3015
|
-
const e = await
|
|
3018
|
+
const e = await As(s, t, o);
|
|
3016
3019
|
if (e.error != null)
|
|
3017
3020
|
return `Method: playwright-browser-list(${JSON.stringify(s)})
|
|
3018
3021
|
❌ Error: ${e.error}`;
|
|
@@ -3024,15 +3027,15 @@ ${n.length === 0 ? "No browsers found" : `Browsers: ${n.join(", ")}`}`;
|
|
|
3024
3027
|
}
|
|
3025
3028
|
);
|
|
3026
3029
|
}
|
|
3027
|
-
const
|
|
3030
|
+
const Ft = h.object({
|
|
3028
3031
|
names: h.array(h.string()).optional().describe(
|
|
3029
3032
|
"Names of browsers to close. If not specified, closes all browsers"
|
|
3030
3033
|
)
|
|
3031
3034
|
});
|
|
3032
|
-
async function
|
|
3035
|
+
async function Us(r, t, s) {
|
|
3033
3036
|
let o;
|
|
3034
3037
|
try {
|
|
3035
|
-
o =
|
|
3038
|
+
o = Ft.parse(r);
|
|
3036
3039
|
} catch (l) {
|
|
3037
3040
|
return {
|
|
3038
3041
|
error: F(l)
|
|
@@ -3063,16 +3066,16 @@ async function Ls(t, r, s) {
|
|
|
3063
3066
|
...a.length > 0 && { errors: a }
|
|
3064
3067
|
};
|
|
3065
3068
|
}
|
|
3066
|
-
function
|
|
3067
|
-
|
|
3069
|
+
function js(r, t) {
|
|
3070
|
+
r(
|
|
3068
3071
|
"playwright-browser-close",
|
|
3069
3072
|
{
|
|
3070
3073
|
title: "Close Browsers",
|
|
3071
3074
|
description: "Close browsers. Automatically closes all contexts and pages within the browsers",
|
|
3072
|
-
inputSchema:
|
|
3075
|
+
inputSchema: Ft.shape
|
|
3073
3076
|
},
|
|
3074
3077
|
async (s, o) => {
|
|
3075
|
-
const e = await
|
|
3078
|
+
const e = await Us(s, t, o);
|
|
3076
3079
|
if (e.error != null)
|
|
3077
3080
|
return `Method: playwright-browser-close(${JSON.stringify(s)})
|
|
3078
3081
|
❌ Error: ${e.error}`;
|
|
@@ -3104,10 +3107,10 @@ const Me = h.object({
|
|
|
3104
3107
|
height: h.number()
|
|
3105
3108
|
}).optional().describe("Viewport size configuration")
|
|
3106
3109
|
});
|
|
3107
|
-
async function
|
|
3110
|
+
async function Bt(r, t, s) {
|
|
3108
3111
|
let o;
|
|
3109
3112
|
try {
|
|
3110
|
-
o = Me.parse(
|
|
3113
|
+
o = Me.parse(r);
|
|
3111
3114
|
} catch (p) {
|
|
3112
3115
|
return {
|
|
3113
3116
|
error: F(p)
|
|
@@ -3130,7 +3133,7 @@ async function Rt(t, r, s) {
|
|
|
3130
3133
|
error: `Browser "${n}" not found`
|
|
3131
3134
|
};
|
|
3132
3135
|
} else if (i) {
|
|
3133
|
-
const p = await
|
|
3136
|
+
const p = await Dt(i, t, s);
|
|
3134
3137
|
if (p.error != null)
|
|
3135
3138
|
return {
|
|
3136
3139
|
error: p.error
|
|
@@ -3162,8 +3165,8 @@ async function Rt(t, r, s) {
|
|
|
3162
3165
|
};
|
|
3163
3166
|
}
|
|
3164
3167
|
}
|
|
3165
|
-
function
|
|
3166
|
-
|
|
3168
|
+
function qs(r, t) {
|
|
3169
|
+
r(
|
|
3167
3170
|
"playwright-context-create",
|
|
3168
3171
|
{
|
|
3169
3172
|
title: "Create Browser Context",
|
|
@@ -3171,7 +3174,7 @@ function As(t, r) {
|
|
|
3171
3174
|
inputSchema: Me.shape
|
|
3172
3175
|
},
|
|
3173
3176
|
async (s, o) => {
|
|
3174
|
-
const e = await
|
|
3177
|
+
const e = await Bt(s, t, o);
|
|
3175
3178
|
if (e.error != null)
|
|
3176
3179
|
return `Method: playwright-context-create(${JSON.stringify(s)})
|
|
3177
3180
|
❌ Error: ${e.error}`;
|
|
@@ -3182,15 +3185,15 @@ function As(t, r) {
|
|
|
3182
3185
|
}
|
|
3183
3186
|
);
|
|
3184
3187
|
}
|
|
3185
|
-
const
|
|
3188
|
+
const Lt = h.object({
|
|
3186
3189
|
browserName: h.string().optional().describe(
|
|
3187
3190
|
"Name of browser to list contexts from. If not specified, lists contexts from all browsers"
|
|
3188
3191
|
)
|
|
3189
3192
|
});
|
|
3190
|
-
async function
|
|
3193
|
+
async function Gs(r, t, s) {
|
|
3191
3194
|
let o;
|
|
3192
3195
|
try {
|
|
3193
|
-
o =
|
|
3196
|
+
o = Lt.parse(r);
|
|
3194
3197
|
} catch (a) {
|
|
3195
3198
|
return {
|
|
3196
3199
|
error: F(a)
|
|
@@ -3224,16 +3227,16 @@ async function zs(t, r, s) {
|
|
|
3224
3227
|
contextsByBrowser: i
|
|
3225
3228
|
};
|
|
3226
3229
|
}
|
|
3227
|
-
function
|
|
3228
|
-
|
|
3230
|
+
function _s(r, t) {
|
|
3231
|
+
r(
|
|
3229
3232
|
"playwright-context-list",
|
|
3230
3233
|
{
|
|
3231
3234
|
title: "List Browser Contexts",
|
|
3232
3235
|
description: "List active browser contexts",
|
|
3233
|
-
inputSchema:
|
|
3236
|
+
inputSchema: Lt.shape
|
|
3234
3237
|
},
|
|
3235
3238
|
async (s, o) => {
|
|
3236
|
-
const e = await
|
|
3239
|
+
const e = await Gs(s, t, o);
|
|
3237
3240
|
if ("error" in e)
|
|
3238
3241
|
return `Method: playwright-context-list(${JSON.stringify(s)})
|
|
3239
3242
|
❌ Error: ${e.error}`;
|
|
@@ -3246,7 +3249,7 @@ function Us(t, r) {
|
|
|
3246
3249
|
}
|
|
3247
3250
|
);
|
|
3248
3251
|
}
|
|
3249
|
-
const
|
|
3252
|
+
const Pt = h.object({
|
|
3250
3253
|
names: h.array(h.string()).optional().describe(
|
|
3251
3254
|
"Names of contexts to close. If not specified, closes all contexts"
|
|
3252
3255
|
),
|
|
@@ -3254,10 +3257,10 @@ const Bt = h.object({
|
|
|
3254
3257
|
"Name of browser to close contexts from. If not specified, searches all browsers"
|
|
3255
3258
|
)
|
|
3256
3259
|
});
|
|
3257
|
-
async function
|
|
3260
|
+
async function Js(r, t, s) {
|
|
3258
3261
|
let o;
|
|
3259
3262
|
try {
|
|
3260
|
-
o =
|
|
3263
|
+
o = Pt.parse(r);
|
|
3261
3264
|
} catch (u) {
|
|
3262
3265
|
return {
|
|
3263
3266
|
error: F(u)
|
|
@@ -3308,16 +3311,16 @@ async function qs(t, r, s) {
|
|
|
3308
3311
|
...c.length > 0 && { errors: c }
|
|
3309
3312
|
};
|
|
3310
3313
|
}
|
|
3311
|
-
function
|
|
3312
|
-
|
|
3314
|
+
function Ks(r, t) {
|
|
3315
|
+
r(
|
|
3313
3316
|
"playwright-context-close",
|
|
3314
3317
|
{
|
|
3315
3318
|
title: "Close Browser Contexts",
|
|
3316
3319
|
description: "Close browser contexts. Automatically closes all pages within the contexts",
|
|
3317
|
-
inputSchema:
|
|
3320
|
+
inputSchema: Pt.shape
|
|
3318
3321
|
},
|
|
3319
3322
|
async (s, o) => {
|
|
3320
|
-
const e = await
|
|
3323
|
+
const e = await Js(s, t, o);
|
|
3321
3324
|
if ("error" in e)
|
|
3322
3325
|
return `Method: playwright-context-close(${JSON.stringify(s)})
|
|
3323
3326
|
❌ Error: ${e.error}`;
|
|
@@ -3334,8 +3337,8 @@ ${n.join(`
|
|
|
3334
3337
|
}
|
|
3335
3338
|
);
|
|
3336
3339
|
}
|
|
3337
|
-
function
|
|
3338
|
-
class
|
|
3340
|
+
function Ws() {
|
|
3341
|
+
class r {
|
|
3339
3342
|
prevId = 0;
|
|
3340
3343
|
objectToId = /* @__PURE__ */ new WeakMap();
|
|
3341
3344
|
idToObject = /* @__PURE__ */ new Map();
|
|
@@ -3357,16 +3360,16 @@ function _s() {
|
|
|
3357
3360
|
return u ?? (this.idToObject.delete(c), null);
|
|
3358
3361
|
}
|
|
3359
3362
|
}
|
|
3360
|
-
function
|
|
3363
|
+
function t(a, c, l) {
|
|
3361
3364
|
let u = null;
|
|
3362
3365
|
for (let f = 0, d = c.length; f < d; f++) {
|
|
3363
|
-
const p = c[f], g = a(p), m = g == null ? null :
|
|
3366
|
+
const p = c[f], g = a(p), m = g == null ? null : t(a, g, l), y = l(p, m);
|
|
3364
3367
|
y != null && (u == null && (u = []), u.push(y));
|
|
3365
3368
|
}
|
|
3366
3369
|
return u;
|
|
3367
3370
|
}
|
|
3368
3371
|
function s(a) {
|
|
3369
|
-
const { getId: c, getChilds: l, rootNodes: u, createSnapshotNode: f } = a, d = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), m =
|
|
3372
|
+
const { getId: c, getChilds: l, rootNodes: u, createSnapshotNode: f } = a, d = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), m = t(
|
|
3370
3373
|
l,
|
|
3371
3374
|
u,
|
|
3372
3375
|
(w, M) => {
|
|
@@ -3410,7 +3413,7 @@ function _s() {
|
|
|
3410
3413
|
};
|
|
3411
3414
|
};
|
|
3412
3415
|
}
|
|
3413
|
-
const n = new
|
|
3416
|
+
const n = new r();
|
|
3414
3417
|
function i(a) {
|
|
3415
3418
|
const c = e(a);
|
|
3416
3419
|
return s({
|
|
@@ -3422,7 +3425,7 @@ function _s() {
|
|
|
3422
3425
|
}
|
|
3423
3426
|
window.__mcp_playwright_tool_tx4byhar35_createDomSnapshotTreeRawDom = i;
|
|
3424
3427
|
}
|
|
3425
|
-
const
|
|
3428
|
+
const Hs = `(function (){function __name(fn){return fn};${Ws.toString()}; setupPageGlobals();})()`, Te = h.object({
|
|
3426
3429
|
contextName: h.string().optional().describe("Name of previously created context, to use"),
|
|
3427
3430
|
context: Me.optional().describe(
|
|
3428
3431
|
"Context creation options JSON to automatically create context"
|
|
@@ -3431,10 +3434,10 @@ const Js = `(function (){function __name(fn){return fn};${_s.toString()}; setupP
|
|
|
3431
3434
|
"Unique name for the page. Recommended format: kebab-case-1, kebab-case-2, ..."
|
|
3432
3435
|
)
|
|
3433
3436
|
});
|
|
3434
|
-
async function
|
|
3437
|
+
async function At(r, t, s) {
|
|
3435
3438
|
let o;
|
|
3436
3439
|
try {
|
|
3437
|
-
o = Te.parse(
|
|
3440
|
+
o = Te.parse(r);
|
|
3438
3441
|
} catch (f) {
|
|
3439
3442
|
return {
|
|
3440
3443
|
error: F(f)
|
|
@@ -3462,7 +3465,7 @@ async function Lt(t, r, s) {
|
|
|
3462
3465
|
error: `Context "${n}" not found`
|
|
3463
3466
|
};
|
|
3464
3467
|
} else if (i) {
|
|
3465
|
-
const f = await
|
|
3468
|
+
const f = await Bt(i, t, s);
|
|
3466
3469
|
if (f.error != null)
|
|
3467
3470
|
return {
|
|
3468
3471
|
error: f.error
|
|
@@ -3474,7 +3477,7 @@ async function Lt(t, r, s) {
|
|
|
3474
3477
|
};
|
|
3475
3478
|
try {
|
|
3476
3479
|
const f = await u.context.newPage();
|
|
3477
|
-
await f.addInitScript(
|
|
3480
|
+
await f.addInitScript(Hs), await f.goto("about:blank");
|
|
3478
3481
|
const d = {
|
|
3479
3482
|
contextInfo: u,
|
|
3480
3483
|
name: e,
|
|
@@ -3492,8 +3495,8 @@ async function Lt(t, r, s) {
|
|
|
3492
3495
|
};
|
|
3493
3496
|
}
|
|
3494
3497
|
}
|
|
3495
|
-
function
|
|
3496
|
-
|
|
3498
|
+
function Qs(r, t) {
|
|
3499
|
+
r(
|
|
3497
3500
|
"playwright-page-create",
|
|
3498
3501
|
{
|
|
3499
3502
|
title: "Create Page",
|
|
@@ -3501,7 +3504,7 @@ function js(t, r) {
|
|
|
3501
3504
|
inputSchema: Te.shape
|
|
3502
3505
|
},
|
|
3503
3506
|
async (s, o) => {
|
|
3504
|
-
const e = await
|
|
3507
|
+
const e = await At(s, t, o);
|
|
3505
3508
|
if (e.error != null)
|
|
3506
3509
|
return `Method: playwright-page-create(${JSON.stringify(s)})
|
|
3507
3510
|
❌ Error: ${e.error}`;
|
|
@@ -3513,7 +3516,7 @@ function js(t, r) {
|
|
|
3513
3516
|
}
|
|
3514
3517
|
);
|
|
3515
3518
|
}
|
|
3516
|
-
const
|
|
3519
|
+
const zt = h.object({
|
|
3517
3520
|
contextName: h.string().optional().describe(
|
|
3518
3521
|
"Name of context to list pages from. If not specified, lists pages from all contexts"
|
|
3519
3522
|
),
|
|
@@ -3521,10 +3524,10 @@ const Pt = h.object({
|
|
|
3521
3524
|
"Name of browser to search in. If not specified, searches all browsers"
|
|
3522
3525
|
)
|
|
3523
3526
|
});
|
|
3524
|
-
async function
|
|
3527
|
+
async function Ys(r, t, s) {
|
|
3525
3528
|
let o;
|
|
3526
3529
|
try {
|
|
3527
|
-
o =
|
|
3530
|
+
o = zt.parse(r);
|
|
3528
3531
|
} catch (c) {
|
|
3529
3532
|
return {
|
|
3530
3533
|
error: F(c)
|
|
@@ -3585,16 +3588,16 @@ async function Ks(t, r, s) {
|
|
|
3585
3588
|
pagesByContext: a
|
|
3586
3589
|
};
|
|
3587
3590
|
}
|
|
3588
|
-
function
|
|
3589
|
-
|
|
3591
|
+
function Vs(r, t) {
|
|
3592
|
+
r(
|
|
3590
3593
|
"playwright-page-list",
|
|
3591
3594
|
{
|
|
3592
3595
|
title: "List Pages",
|
|
3593
3596
|
description: "List active pages",
|
|
3594
|
-
inputSchema:
|
|
3597
|
+
inputSchema: zt.shape
|
|
3595
3598
|
},
|
|
3596
3599
|
async (s, o) => {
|
|
3597
|
-
const e = await
|
|
3600
|
+
const e = await Ys(s, t, o);
|
|
3598
3601
|
if ("error" in e)
|
|
3599
3602
|
return `Method: playwright-page-list(${JSON.stringify(s)})
|
|
3600
3603
|
❌ Error: ${e.error}`;
|
|
@@ -3607,7 +3610,7 @@ function Ws(t, r) {
|
|
|
3607
3610
|
}
|
|
3608
3611
|
);
|
|
3609
3612
|
}
|
|
3610
|
-
const
|
|
3613
|
+
const Ut = h.object({
|
|
3611
3614
|
names: h.array(h.string()).optional().describe("Names of pages to close. If not specified, closes all pages"),
|
|
3612
3615
|
contextName: h.string().optional().describe(
|
|
3613
3616
|
"Name of context to close pages from. If not specified, searches all contexts"
|
|
@@ -3616,10 +3619,10 @@ const At = h.object({
|
|
|
3616
3619
|
"Name of browser to search in. If not specified, searches all browsers"
|
|
3617
3620
|
)
|
|
3618
3621
|
});
|
|
3619
|
-
async function
|
|
3622
|
+
async function Zs(r, t, s) {
|
|
3620
3623
|
let o;
|
|
3621
3624
|
try {
|
|
3622
|
-
o =
|
|
3625
|
+
o = Ut.parse(r);
|
|
3623
3626
|
} catch (f) {
|
|
3624
3627
|
return {
|
|
3625
3628
|
error: F(f)
|
|
@@ -3694,16 +3697,16 @@ async function Hs(t, r, s) {
|
|
|
3694
3697
|
...l.length > 0 && { errors: l }
|
|
3695
3698
|
};
|
|
3696
3699
|
}
|
|
3697
|
-
function
|
|
3698
|
-
|
|
3700
|
+
function Xs(r, t) {
|
|
3701
|
+
r(
|
|
3699
3702
|
"playwright-page-close",
|
|
3700
3703
|
{
|
|
3701
3704
|
title: "Close Pages",
|
|
3702
3705
|
description: "Close pages",
|
|
3703
|
-
inputSchema:
|
|
3706
|
+
inputSchema: Ut.shape
|
|
3704
3707
|
},
|
|
3705
3708
|
async (s, o) => {
|
|
3706
|
-
const e = await
|
|
3709
|
+
const e = await Zs(s, t, o);
|
|
3707
3710
|
if ("error" in e)
|
|
3708
3711
|
return `Method: playwright-page-close(${JSON.stringify(s)})
|
|
3709
3712
|
❌ Error: ${e.error}`;
|
|
@@ -3714,7 +3717,7 @@ ${n.join(`
|
|
|
3714
3717
|
}
|
|
3715
3718
|
);
|
|
3716
3719
|
}
|
|
3717
|
-
const
|
|
3720
|
+
const jt = h.object({
|
|
3718
3721
|
pageName: h.string().optional().describe("Name of previously created page to navigate"),
|
|
3719
3722
|
page: Te.optional().describe(
|
|
3720
3723
|
"Page creation options JSON to automatically create page"
|
|
@@ -3729,10 +3732,10 @@ const zt = h.object({
|
|
|
3729
3732
|
- 'commit': network response received and document started loading`
|
|
3730
3733
|
)
|
|
3731
3734
|
});
|
|
3732
|
-
async function
|
|
3735
|
+
async function eo(r, t, s) {
|
|
3733
3736
|
let o;
|
|
3734
3737
|
try {
|
|
3735
|
-
o =
|
|
3738
|
+
o = jt.parse(r);
|
|
3736
3739
|
} catch (g) {
|
|
3737
3740
|
return {
|
|
3738
3741
|
error: F(g)
|
|
@@ -3763,7 +3766,7 @@ async function Ys(t, r, s) {
|
|
|
3763
3766
|
error: `Page "${e}" not found`
|
|
3764
3767
|
};
|
|
3765
3768
|
} else if (n) {
|
|
3766
|
-
const g = await
|
|
3769
|
+
const g = await At(n, t, s);
|
|
3767
3770
|
if (g.error != null)
|
|
3768
3771
|
return {
|
|
3769
3772
|
error: g.error
|
|
@@ -3797,16 +3800,16 @@ async function Ys(t, r, s) {
|
|
|
3797
3800
|
};
|
|
3798
3801
|
}
|
|
3799
3802
|
}
|
|
3800
|
-
function
|
|
3801
|
-
|
|
3803
|
+
function to(r, t) {
|
|
3804
|
+
r(
|
|
3802
3805
|
"playwright-page-goto",
|
|
3803
3806
|
{
|
|
3804
3807
|
title: "Navigate Page",
|
|
3805
3808
|
description: "Navigate page to URL. Use for manual browser interaction",
|
|
3806
|
-
inputSchema:
|
|
3809
|
+
inputSchema: jt.shape
|
|
3807
3810
|
},
|
|
3808
3811
|
async (s, o) => {
|
|
3809
|
-
const e = await
|
|
3812
|
+
const e = await eo(s, t, o);
|
|
3810
3813
|
if (e.error != null)
|
|
3811
3814
|
return `Method: playwright-page-goto(${JSON.stringify(s)})
|
|
3812
3815
|
❌ Error: ${e.error}`;
|
|
@@ -3825,10 +3828,10 @@ const Ce = h.object({
|
|
|
3825
3828
|
),
|
|
3826
3829
|
cssSelector: h.string().describe("CSS selector to capture page content")
|
|
3827
3830
|
});
|
|
3828
|
-
async function
|
|
3831
|
+
async function qt(r, t, s) {
|
|
3829
3832
|
let o;
|
|
3830
3833
|
try {
|
|
3831
|
-
o = Ce.parse(
|
|
3834
|
+
o = Ce.parse(r);
|
|
3832
3835
|
} catch (c) {
|
|
3833
3836
|
return {
|
|
3834
3837
|
error: F(c)
|
|
@@ -3847,8 +3850,8 @@ async function Ut(t, r, s) {
|
|
|
3847
3850
|
snapshotQuery: a
|
|
3848
3851
|
};
|
|
3849
3852
|
}
|
|
3850
|
-
function
|
|
3851
|
-
|
|
3853
|
+
function ro(r, t) {
|
|
3854
|
+
r(
|
|
3852
3855
|
"playwright-dom-snapshot-query-create",
|
|
3853
3856
|
{
|
|
3854
3857
|
title: "Create DOM Snapshot Query",
|
|
@@ -3856,14 +3859,14 @@ function Zs(t, r) {
|
|
|
3856
3859
|
inputSchema: Ce.shape
|
|
3857
3860
|
},
|
|
3858
3861
|
async (s, o) => {
|
|
3859
|
-
const e = await
|
|
3862
|
+
const e = await qt(s, t, o);
|
|
3860
3863
|
return e.error != null ? `Method: playwright-dom-snapshot-query-create(${JSON.stringify(s)})
|
|
3861
3864
|
❌ Error: ${e.error}` : `Method: playwright-dom-snapshot-query-create(${JSON.stringify(s)})
|
|
3862
3865
|
✅ DOM snapshot query "${e.snapshotQuery.name}" created successfully`;
|
|
3863
3866
|
}
|
|
3864
3867
|
);
|
|
3865
3868
|
}
|
|
3866
|
-
function
|
|
3869
|
+
function so(r) {
|
|
3867
3870
|
return function(s, o) {
|
|
3868
3871
|
let e, n = 0;
|
|
3869
3872
|
const i = o ? o.length : 0;
|
|
@@ -3884,7 +3887,7 @@ function Xs(t) {
|
|
|
3884
3887
|
textOpen: `<root uid:${u}>`,
|
|
3885
3888
|
textClose: "</root>"
|
|
3886
3889
|
};
|
|
3887
|
-
const p =
|
|
3890
|
+
const p = It(d);
|
|
3888
3891
|
return l += p, {
|
|
3889
3892
|
uid: u,
|
|
3890
3893
|
tagName: f,
|
|
@@ -3899,8 +3902,8 @@ function Xs(t) {
|
|
|
3899
3902
|
};
|
|
3900
3903
|
};
|
|
3901
3904
|
}
|
|
3902
|
-
function
|
|
3903
|
-
const s = le(
|
|
3905
|
+
function oo(r, t) {
|
|
3906
|
+
const s = le(t), o = s.getChilds(s.root), e = $t({
|
|
3904
3907
|
getId: (n) => {
|
|
3905
3908
|
const i = s.getId(n);
|
|
3906
3909
|
if (i == null)
|
|
@@ -3910,7 +3913,7 @@ function eo(t, r) {
|
|
|
3910
3913
|
return i;
|
|
3911
3914
|
},
|
|
3912
3915
|
getChilds: (n) => s.getChilds(n),
|
|
3913
|
-
createSnapshotNode:
|
|
3916
|
+
createSnapshotNode: so(),
|
|
3914
3917
|
rootNodes: o ?? []
|
|
3915
3918
|
});
|
|
3916
3919
|
return le(e);
|
|
@@ -3925,10 +3928,10 @@ const ve = h.object({
|
|
|
3925
3928
|
"Unique name for the DOM snapshot. Recommended format: kebab-case-1, kebab-case-2, ..."
|
|
3926
3929
|
)
|
|
3927
3930
|
});
|
|
3928
|
-
async function
|
|
3931
|
+
async function Gt(r, t, s) {
|
|
3929
3932
|
let o;
|
|
3930
3933
|
try {
|
|
3931
|
-
o = ve.parse(
|
|
3934
|
+
o = ve.parse(r);
|
|
3932
3935
|
} catch (d) {
|
|
3933
3936
|
return {
|
|
3934
3937
|
error: F(d)
|
|
@@ -3966,9 +3969,9 @@ async function qt(t, r, s) {
|
|
|
3966
3969
|
};
|
|
3967
3970
|
u = d;
|
|
3968
3971
|
} else if (i) {
|
|
3969
|
-
const d = await
|
|
3972
|
+
const d = await qt(
|
|
3970
3973
|
i,
|
|
3971
|
-
|
|
3974
|
+
t,
|
|
3972
3975
|
s
|
|
3973
3976
|
);
|
|
3974
3977
|
if (d.error != null)
|
|
@@ -3996,7 +3999,7 @@ async function qt(t, r, s) {
|
|
|
3996
3999
|
), p = {
|
|
3997
4000
|
idToNode: new Map(d.idToNode),
|
|
3998
4001
|
idToChildIds: new Map(d.idToChildIds)
|
|
3999
|
-
}, g =
|
|
4002
|
+
}, g = oo(u, p), m = {
|
|
4000
4003
|
name: a,
|
|
4001
4004
|
query: u,
|
|
4002
4005
|
tree: g
|
|
@@ -4011,8 +4014,8 @@ async function qt(t, r, s) {
|
|
|
4011
4014
|
};
|
|
4012
4015
|
}
|
|
4013
4016
|
}
|
|
4014
|
-
function
|
|
4015
|
-
|
|
4017
|
+
function no(r, t) {
|
|
4018
|
+
r(
|
|
4016
4019
|
"playwright-dom-snapshot-create",
|
|
4017
4020
|
{
|
|
4018
4021
|
title: "Create DOM Snapshot",
|
|
@@ -4020,7 +4023,7 @@ function to(t, r) {
|
|
|
4020
4023
|
inputSchema: ve.shape
|
|
4021
4024
|
},
|
|
4022
4025
|
async (s, o) => {
|
|
4023
|
-
const e = await
|
|
4026
|
+
const e = await Gt(s, t, o);
|
|
4024
4027
|
if (e.error != null)
|
|
4025
4028
|
return `Method: playwright-dom-snapshot-create(${JSON.stringify(s)})
|
|
4026
4029
|
❌ Error: ${e.error}`;
|
|
@@ -4031,21 +4034,21 @@ function to(t, r) {
|
|
|
4031
4034
|
}
|
|
4032
4035
|
);
|
|
4033
4036
|
}
|
|
4034
|
-
class
|
|
4037
|
+
class io {
|
|
4035
4038
|
tokens = 20;
|
|
4036
|
-
getReportText = (
|
|
4039
|
+
getReportText = (t) => ({
|
|
4037
4040
|
indent: !0,
|
|
4038
|
-
textOpen: `[${
|
|
4041
|
+
textOpen: `[${t.indexRange[0]}-${t.indexRange[1]}] see more ${t.countMatched} matched ${t.tokensGrouped} tokens`,
|
|
4039
4042
|
textClose: null
|
|
4040
4043
|
});
|
|
4041
|
-
add = (
|
|
4044
|
+
add = (t, s, o) => t == null ? {
|
|
4042
4045
|
indexRange: [o, o],
|
|
4043
4046
|
countGrouped: 1,
|
|
4044
4047
|
countMatched: s.countMatched,
|
|
4045
4048
|
tokensGrouped: s.tokens
|
|
4046
|
-
} : (
|
|
4049
|
+
} : (t.indexRange[1] = o, t.countGrouped += 1, t.countMatched += s.countMatched, t.tokensGrouped += s.tokens, t);
|
|
4047
4050
|
}
|
|
4048
|
-
const
|
|
4051
|
+
const _t = h.object({
|
|
4049
4052
|
snapshotName: h.string().optional().describe("Name of previously created DOM snapshot, to use"),
|
|
4050
4053
|
snapshot: ve.optional().describe(
|
|
4051
4054
|
"DOM snapshot creation options JSON to automatically create snapshot"
|
|
@@ -4065,10 +4068,10 @@ const Gt = h.object({
|
|
|
4065
4068
|
// maxCountGroup: z.number().default(10).describe('Maximum items per group'),
|
|
4066
4069
|
// maxTokensGroup: z.number().default(1000).describe('Maximum tokens per group'),
|
|
4067
4070
|
});
|
|
4068
|
-
async function
|
|
4071
|
+
async function ao(r, t, s) {
|
|
4069
4072
|
let o;
|
|
4070
4073
|
try {
|
|
4071
|
-
o =
|
|
4074
|
+
o = _t.parse(r);
|
|
4072
4075
|
} catch (m) {
|
|
4073
4076
|
return {
|
|
4074
4077
|
error: F(m)
|
|
@@ -4110,9 +4113,9 @@ async function so(t, r, s) {
|
|
|
4110
4113
|
error: `DOM snapshot "${e}" not found`
|
|
4111
4114
|
};
|
|
4112
4115
|
} else if (n) {
|
|
4113
|
-
const m = await
|
|
4116
|
+
const m = await Gt(
|
|
4114
4117
|
n,
|
|
4115
|
-
|
|
4118
|
+
t,
|
|
4116
4119
|
s
|
|
4117
4120
|
);
|
|
4118
4121
|
if (m.error != null)
|
|
@@ -4125,7 +4128,7 @@ async function so(t, r, s) {
|
|
|
4125
4128
|
error: "Either snapshotName or snapshot must be provided"
|
|
4126
4129
|
};
|
|
4127
4130
|
try {
|
|
4128
|
-
const m = o.parentUid, y =
|
|
4131
|
+
const m = o.parentUid, y = Mt({
|
|
4129
4132
|
tree: d.tree,
|
|
4130
4133
|
request: {
|
|
4131
4134
|
parentNodeId: m,
|
|
@@ -4137,8 +4140,8 @@ async function so(t, r, s) {
|
|
|
4137
4140
|
maxTokensGroup: u
|
|
4138
4141
|
}
|
|
4139
4142
|
},
|
|
4140
|
-
indexRangeGroupStrategy: new
|
|
4141
|
-
}), w =
|
|
4143
|
+
indexRangeGroupStrategy: new io()
|
|
4144
|
+
}), w = Tt(y);
|
|
4142
4145
|
return {
|
|
4143
4146
|
domSnapshot: d,
|
|
4144
4147
|
queryCreated: p,
|
|
@@ -4153,16 +4156,16 @@ async function so(t, r, s) {
|
|
|
4153
4156
|
};
|
|
4154
4157
|
}
|
|
4155
4158
|
}
|
|
4156
|
-
function
|
|
4157
|
-
|
|
4159
|
+
function lo(r, t) {
|
|
4160
|
+
r(
|
|
4158
4161
|
"playwright-dom-snapshot-browse",
|
|
4159
4162
|
{
|
|
4160
4163
|
title: "Browse DOM Snapshot",
|
|
4161
4164
|
description: "Browse and explore DOM. Use this to browse, analyze, explore, inspect, etc webpage structure and styles, find elements, or inspect page content",
|
|
4162
|
-
inputSchema:
|
|
4165
|
+
inputSchema: _t.shape
|
|
4163
4166
|
},
|
|
4164
4167
|
async (s, o) => {
|
|
4165
|
-
const e = await
|
|
4168
|
+
const e = await ao(s, t, o);
|
|
4166
4169
|
if (e.error != null)
|
|
4167
4170
|
return `Method: playwright-dom-snapshot-browse(${JSON.stringify(s)})
|
|
4168
4171
|
❌ Error: ${e.error}`;
|
|
@@ -4183,14 +4186,14 @@ ${e.report}`, n;
|
|
|
4183
4186
|
}
|
|
4184
4187
|
);
|
|
4185
4188
|
}
|
|
4186
|
-
function
|
|
4187
|
-
|
|
4189
|
+
function co(r, t) {
|
|
4190
|
+
t.browserCreate && Ps(r, t), t.browserList && zs(r, t), t.browserClose && js(r, t), t.contextCreate && qs(r, t), t.contextList && _s(r, t), t.contextClose && Ks(r, t), t.pageCreate && Qs(r, t), t.pageList && Vs(r, t), t.pageClose && Xs(r, t), t.pageGoto && to(r, t), t.domSnapshotQueryCreate && ro(r, t), t.domSnapshotCreate && no(r, t), t.domSnapshotBrowse && lo(r, t), console.log("Playwright manager");
|
|
4188
4191
|
}
|
|
4189
|
-
function
|
|
4190
|
-
const { logFilePath:
|
|
4192
|
+
function uo(r) {
|
|
4193
|
+
const { logFilePath: t } = r;
|
|
4191
4194
|
return async function(o, e, n, i) {
|
|
4192
4195
|
await ie({
|
|
4193
|
-
logFilePath:
|
|
4196
|
+
logFilePath: t,
|
|
4194
4197
|
message: "ERROR",
|
|
4195
4198
|
data: {
|
|
4196
4199
|
request: {
|
|
@@ -4208,31 +4211,141 @@ function io(t) {
|
|
|
4208
4211
|
});
|
|
4209
4212
|
};
|
|
4210
4213
|
}
|
|
4211
|
-
|
|
4214
|
+
const rt = [
|
|
4215
|
+
"flemist-mcp.config.json",
|
|
4216
|
+
"flemist-mcp.config.json5",
|
|
4217
|
+
"flemist-mcp.config.yaml"
|
|
4218
|
+
];
|
|
4219
|
+
async function fo(r) {
|
|
4220
|
+
const t = k.resolve(r);
|
|
4221
|
+
for (let s = 0, o = rt.length; s < o; s++) {
|
|
4222
|
+
const e = rt[s], n = k.join(t, e);
|
|
4223
|
+
try {
|
|
4224
|
+
await j.promises.stat(n);
|
|
4225
|
+
} catch {
|
|
4226
|
+
continue;
|
|
4227
|
+
}
|
|
4228
|
+
console.log(`Loading configuration from: ${n}`);
|
|
4229
|
+
let i;
|
|
4230
|
+
try {
|
|
4231
|
+
i = await j.promises.readFile(n, "utf-8");
|
|
4232
|
+
} catch (c) {
|
|
4233
|
+
throw new Error(`MCP Error: Failed to read config file: ${n}
|
|
4234
|
+
|
|
4235
|
+
${c instanceof Error ? c.message : String(c)}`);
|
|
4236
|
+
}
|
|
4237
|
+
const a = k.extname(e);
|
|
4238
|
+
try {
|
|
4239
|
+
if (a === ".json")
|
|
4240
|
+
return Ee.parse(i);
|
|
4241
|
+
if (a === ".json5")
|
|
4242
|
+
return Ee.parse(i);
|
|
4243
|
+
if (a === ".yaml")
|
|
4244
|
+
return ir.load(i);
|
|
4245
|
+
} catch (c) {
|
|
4246
|
+
throw new Error(`MCP Error: Failed to parse config file: ${n}
|
|
4247
|
+
|
|
4248
|
+
${c instanceof Error ? c.message : String(c)}`);
|
|
4249
|
+
}
|
|
4250
|
+
}
|
|
4251
|
+
throw new Error(`MCP Error: No configuration file found in: ${t}
|
|
4252
|
+
|
|
4253
|
+
Expected one of:
|
|
4254
|
+
- flemist-mcp.config.json
|
|
4255
|
+
- flemist-mcp.config.json5
|
|
4256
|
+
- flemist-mcp.config.yaml`);
|
|
4257
|
+
}
|
|
4258
|
+
const po = {
|
|
4259
|
+
logDir: "tmp/mcp-project-tools/logs",
|
|
4260
|
+
tools: {
|
|
4261
|
+
processManager: {
|
|
4262
|
+
workingDir: null,
|
|
4263
|
+
commandLineRules: [],
|
|
4264
|
+
run: !0,
|
|
4265
|
+
status: !0,
|
|
4266
|
+
wait: !0,
|
|
4267
|
+
list: !0,
|
|
4268
|
+
kill: !0
|
|
4269
|
+
},
|
|
4270
|
+
fsManager: {
|
|
4271
|
+
workingDir: null,
|
|
4272
|
+
globsExclude: null,
|
|
4273
|
+
list: !0,
|
|
4274
|
+
snapshotQueryCreate: !0,
|
|
4275
|
+
snapshotCreate: !0,
|
|
4276
|
+
snapshotBrowse: !0,
|
|
4277
|
+
snapshotSearch: !0,
|
|
4278
|
+
snapshotReplace: !0
|
|
4279
|
+
},
|
|
4280
|
+
playwrightManager: {
|
|
4281
|
+
browserCreate: !0,
|
|
4282
|
+
browserList: !0,
|
|
4283
|
+
browserClose: !0,
|
|
4284
|
+
contextCreate: !0,
|
|
4285
|
+
contextList: !0,
|
|
4286
|
+
contextClose: !0,
|
|
4287
|
+
pageCreate: !0,
|
|
4288
|
+
pageList: !0,
|
|
4289
|
+
pageClose: !0,
|
|
4290
|
+
pageGoto: !0,
|
|
4291
|
+
domSnapshotQueryCreate: !0,
|
|
4292
|
+
domSnapshotCreate: !0,
|
|
4293
|
+
domSnapshotBrowse: !0
|
|
4294
|
+
}
|
|
4295
|
+
}
|
|
4296
|
+
};
|
|
4297
|
+
async function ho(r) {
|
|
4298
|
+
const t = k.resolve(r), s = await fo(t), o = k.join(t, ".flemist-mcpignore");
|
|
4299
|
+
try {
|
|
4300
|
+
await j.promises.stat(o);
|
|
4301
|
+
} catch {
|
|
4302
|
+
throw new Error(`MCP Error: .flemist-mcpignore file not found in project directory.
|
|
4303
|
+
|
|
4304
|
+
Create .flemist-mcpignore file in: ${t}
|
|
4305
|
+
|
|
4306
|
+
This file contains glob patterns for files/directories to exclude from MCP operations.`);
|
|
4307
|
+
}
|
|
4308
|
+
const e = nr(po, s, {
|
|
4309
|
+
arrayMerge(n, i) {
|
|
4310
|
+
return i;
|
|
4311
|
+
}
|
|
4312
|
+
});
|
|
4313
|
+
return e.tools?.processManager && !e.tools.processManager.workingDir && (e.tools.processManager.workingDir = t), e.tools?.fsManager && !e.tools.fsManager.workingDir && (e.tools.fsManager.workingDir = t), e.tools?.fsManager && (e.tools.fsManager.globsExclude = [
|
|
4314
|
+
{
|
|
4315
|
+
value: o,
|
|
4316
|
+
valueType: "file-contains-patterns",
|
|
4317
|
+
exclude: !0
|
|
4318
|
+
},
|
|
4319
|
+
...e.tools.fsManager.globsExclude || []
|
|
4320
|
+
]), e.tools.fsManager?.globsExclude?.forEach((n, i, a) => {
|
|
4321
|
+
n.valueType === "file-contains-patterns" && (a[i].value = k.resolve(t, n.value));
|
|
4322
|
+
}), e.logDir = k.resolve(t, e.logDir), e;
|
|
4323
|
+
}
|
|
4324
|
+
function Jt() {
|
|
4212
4325
|
return `mcp_${(/* @__PURE__ */ new Date()).toISOString().substring(0, 19).replace(/T/, "_").replace(/:/g, "-")}.log`;
|
|
4213
4326
|
}
|
|
4214
|
-
function
|
|
4215
|
-
const
|
|
4216
|
-
return
|
|
4327
|
+
function mo(r) {
|
|
4328
|
+
const t = ne(), s = go();
|
|
4329
|
+
return t.use(s), t;
|
|
4217
4330
|
}
|
|
4218
|
-
function
|
|
4219
|
-
const
|
|
4220
|
-
return
|
|
4331
|
+
function go(r) {
|
|
4332
|
+
const t = ne.Router();
|
|
4333
|
+
return t.use((s, o, e) => {
|
|
4221
4334
|
s.method === "OPTIONS" ? o.status(403).send("CORS forbidden") : e();
|
|
4222
|
-
}),
|
|
4335
|
+
}), t.use(ne.json()), t;
|
|
4223
4336
|
}
|
|
4224
|
-
function
|
|
4225
|
-
const
|
|
4226
|
-
return
|
|
4337
|
+
function wo(r) {
|
|
4338
|
+
const t = ne.Router();
|
|
4339
|
+
return t.use(ar({ authToken: r.authToken })), t.all("/mcp", fr(r)), t;
|
|
4227
4340
|
}
|
|
4228
|
-
function
|
|
4229
|
-
return
|
|
4341
|
+
function yo(r, t) {
|
|
4342
|
+
return r.use(uo({ logFilePath: t.logFilePath })), new Promise((s, o) => {
|
|
4230
4343
|
let e;
|
|
4231
4344
|
const n = () => {
|
|
4232
4345
|
s(e);
|
|
4233
4346
|
};
|
|
4234
4347
|
try {
|
|
4235
|
-
e =
|
|
4348
|
+
e = t.host ? r.listen(t.port ?? 0, t.host, n) : r.listen(t.port ?? 0, n), e.addListener("error", (i) => {
|
|
4236
4349
|
o(i);
|
|
4237
4350
|
});
|
|
4238
4351
|
} catch (i) {
|
|
@@ -4240,65 +4353,89 @@ function uo(t, r) {
|
|
|
4240
4353
|
}
|
|
4241
4354
|
});
|
|
4242
4355
|
}
|
|
4243
|
-
function
|
|
4244
|
-
if (!
|
|
4356
|
+
function bo(r, t) {
|
|
4357
|
+
if (!r.address())
|
|
4245
4358
|
throw new Error(
|
|
4246
4359
|
"Server address is not available. Check your DNS and host configuration."
|
|
4247
4360
|
);
|
|
4248
|
-
const o =
|
|
4249
|
-
let n =
|
|
4361
|
+
const o = r.address().family, e = r.address().port;
|
|
4362
|
+
let n = r.address().address;
|
|
4250
4363
|
n === "::" ? n = "localhost" : o === "IPv6" && (n = `[${n}]`);
|
|
4251
4364
|
const i = `http://${o === "IPv6" ? `[${n}]` : n}:${e}`;
|
|
4252
4365
|
return `Project Tools - MCP Server Started
|
|
4253
4366
|
|
|
4254
|
-
Server Name: ${
|
|
4255
|
-
Server Version: ${
|
|
4367
|
+
Server Name: ${t.name}
|
|
4368
|
+
Server Version: ${t.version}
|
|
4256
4369
|
Server URL: ${i}/mcp
|
|
4257
4370
|
SSE Endpoint: ${i}/sse
|
|
4258
4371
|
|
|
4259
|
-
Log File: ${
|
|
4372
|
+
Log File: ${k.resolve(t.logFilePath)}`;
|
|
4260
4373
|
}
|
|
4261
|
-
function
|
|
4262
|
-
const s =
|
|
4374
|
+
function So(r, t) {
|
|
4375
|
+
const s = k.join(t.logDir, Jt()), o = Lr(r, {
|
|
4263
4376
|
logFilePath: s
|
|
4264
4377
|
});
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4378
|
+
t.tools.processManager && Br(
|
|
4379
|
+
o,
|
|
4380
|
+
t.tools.processManager
|
|
4381
|
+
), t.tools.fsManager && Ls(o, t.tools.fsManager), t.tools.playwrightManager && co(
|
|
4382
|
+
o,
|
|
4383
|
+
t.tools.playwrightManager
|
|
4384
|
+
), Cr(o);
|
|
4385
|
+
}
|
|
4386
|
+
async function jo(r) {
|
|
4387
|
+
const t = k.join(r.logDir, Jt()), s = mo(), o = wo({
|
|
4388
|
+
authToken: r.authToken,
|
|
4389
|
+
logFilePath: t,
|
|
4390
|
+
createMcpServer: async (n) => {
|
|
4391
|
+
const i = n.headers["x-project-name"];
|
|
4392
|
+
if (!i)
|
|
4393
|
+
throw new Error(`MCP Error: Project not identified.
|
|
4394
|
+
|
|
4395
|
+
X-Project-Name header is missing. To configure MCP for this project:
|
|
4396
|
+
|
|
4397
|
+
1. Ask user: "What is the MCP server address?" (e.g., http://local.host:8000/mcp)
|
|
4398
|
+
2. Ask user: "What project name should I use?" (must match server's projects config)
|
|
4399
|
+
3. Search Claude Code documentation for current .mcp.json format for HTTP MCP servers with custom headers
|
|
4400
|
+
4. Create .mcp.json in project root with X-Project-Name header set to project name
|
|
4401
|
+
5. Ask user to add project to server's projects config if not already present
|
|
4402
|
+
6. Ask user to restart Claude Code`);
|
|
4403
|
+
const a = r.projects[i];
|
|
4404
|
+
if (!a)
|
|
4405
|
+
throw new Error(`MCP Error: Project "${i}" not found in server configuration.
|
|
4406
|
+
|
|
4407
|
+
Ask user to:
|
|
4408
|
+
1. Add project to server's projects config: projects: { "${i}": "<project-path>" }
|
|
4409
|
+
2. Restart MCP server`);
|
|
4410
|
+
const c = await ho(a), l = new Kt({
|
|
4411
|
+
title: r.title,
|
|
4412
|
+
name: r.name,
|
|
4413
|
+
version: r.version
|
|
4278
4414
|
});
|
|
4279
|
-
return
|
|
4415
|
+
return So(l, c), l;
|
|
4280
4416
|
}
|
|
4281
4417
|
});
|
|
4282
4418
|
s.use(o);
|
|
4283
|
-
const e = await
|
|
4284
|
-
host:
|
|
4285
|
-
port:
|
|
4286
|
-
logFilePath:
|
|
4419
|
+
const e = await yo(s, {
|
|
4420
|
+
host: r.host,
|
|
4421
|
+
port: r.port,
|
|
4422
|
+
logFilePath: t
|
|
4287
4423
|
});
|
|
4288
4424
|
return console.log(
|
|
4289
|
-
|
|
4290
|
-
title:
|
|
4291
|
-
name:
|
|
4292
|
-
version:
|
|
4293
|
-
logFilePath:
|
|
4425
|
+
bo(e, {
|
|
4426
|
+
title: r.title,
|
|
4427
|
+
name: r.name,
|
|
4428
|
+
version: r.version,
|
|
4429
|
+
logFilePath: t
|
|
4294
4430
|
})
|
|
4295
4431
|
), e;
|
|
4296
4432
|
}
|
|
4297
4433
|
export {
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4434
|
+
Uo as A,
|
|
4435
|
+
zo as S,
|
|
4436
|
+
Ao as a,
|
|
4437
|
+
Po as b,
|
|
4438
|
+
fo as l,
|
|
4439
|
+
Hr as p,
|
|
4440
|
+
jo as s
|
|
4304
4441
|
};
|