create-vuetify 3.1.6 → 3.2.0-beta.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/dist/ide-config-writer-BEf0T9lZ.mjs +1572 -0
- package/dist/ide-config-writer-DGxLWC5T.mjs +3 -0
- package/dist/index.mjs +111057 -109073
- package/dist/{nypm-BiogvDa_.mjs → nypm-CKxLPI3I.mjs} +2 -2
- package/dist/nypm-dszTlWLQ.mjs +3 -0
- package/dist/{src-CiZqY_Es.mjs → src-BVeWJmfO.mjs} +3 -3
- package/dist/{tar-D0wLsG-Y.mjs → tar-BLDFNugv.mjs} +39 -39
- package/package.json +3 -2
- package/dist/nypm-B0R09qA9.mjs +0 -3
- /package/dist/{jiti-CeHW56Xt.mjs → jiti-CiyXXzPA.mjs} +0 -0
- /package/dist/{rolldown-runtime-1wn-XonI.mjs → rolldown-runtime-CGkscm_g.mjs} +0 -0
|
@@ -0,0 +1,1572 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { constants } from "node:fs";
|
|
3
|
+
import { delimiter } from "node:path";
|
|
4
|
+
import { homedir } from "node:os";
|
|
5
|
+
import { access, mkdir, readFile, readdir, stat, writeFile } from "node:fs/promises";
|
|
6
|
+
//#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
7
|
+
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
8
|
+
function normalizeWindowsPath(input = "") {
|
|
9
|
+
if (!input) return input;
|
|
10
|
+
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
11
|
+
}
|
|
12
|
+
const _UNC_REGEX = /^[/\\]{2}/;
|
|
13
|
+
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
14
|
+
const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
15
|
+
const _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
|
|
16
|
+
const normalize$1 = function(path) {
|
|
17
|
+
if (path.length === 0) return ".";
|
|
18
|
+
path = normalizeWindowsPath(path);
|
|
19
|
+
const isUNCPath = path.match(_UNC_REGEX);
|
|
20
|
+
const isPathAbsolute = isAbsolute$1(path);
|
|
21
|
+
const trailingSeparator = path[path.length - 1] === "/";
|
|
22
|
+
path = normalizeString(path, !isPathAbsolute);
|
|
23
|
+
if (path.length === 0) {
|
|
24
|
+
if (isPathAbsolute) return "/";
|
|
25
|
+
return trailingSeparator ? "./" : ".";
|
|
26
|
+
}
|
|
27
|
+
if (trailingSeparator) path += "/";
|
|
28
|
+
if (_DRIVE_LETTER_RE.test(path)) path += "/";
|
|
29
|
+
if (isUNCPath) {
|
|
30
|
+
if (!isPathAbsolute) return `//./${path}`;
|
|
31
|
+
return `//${path}`;
|
|
32
|
+
}
|
|
33
|
+
return isPathAbsolute && !isAbsolute$1(path) ? `/${path}` : path;
|
|
34
|
+
};
|
|
35
|
+
const join$1 = function(...segments) {
|
|
36
|
+
let path = "";
|
|
37
|
+
for (const seg of segments) {
|
|
38
|
+
if (!seg) continue;
|
|
39
|
+
if (path.length > 0) {
|
|
40
|
+
const pathTrailing = path[path.length - 1] === "/";
|
|
41
|
+
const segLeading = seg[0] === "/";
|
|
42
|
+
if (pathTrailing && segLeading) path += seg.slice(1);
|
|
43
|
+
else path += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
44
|
+
} else path += seg;
|
|
45
|
+
}
|
|
46
|
+
return normalize$1(path);
|
|
47
|
+
};
|
|
48
|
+
function cwd() {
|
|
49
|
+
if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
|
|
50
|
+
return "/";
|
|
51
|
+
}
|
|
52
|
+
const resolve$1 = function(...arguments_) {
|
|
53
|
+
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
54
|
+
let resolvedPath = "";
|
|
55
|
+
let resolvedAbsolute = false;
|
|
56
|
+
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
57
|
+
const path = index >= 0 ? arguments_[index] : cwd();
|
|
58
|
+
if (!path || path.length === 0) continue;
|
|
59
|
+
resolvedPath = `${path}/${resolvedPath}`;
|
|
60
|
+
resolvedAbsolute = isAbsolute$1(path);
|
|
61
|
+
}
|
|
62
|
+
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
63
|
+
if (resolvedAbsolute && !isAbsolute$1(resolvedPath)) return `/${resolvedPath}`;
|
|
64
|
+
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
65
|
+
};
|
|
66
|
+
function normalizeString(path, allowAboveRoot) {
|
|
67
|
+
let res = "";
|
|
68
|
+
let lastSegmentLength = 0;
|
|
69
|
+
let lastSlash = -1;
|
|
70
|
+
let dots = 0;
|
|
71
|
+
let char = null;
|
|
72
|
+
for (let index = 0; index <= path.length; ++index) {
|
|
73
|
+
if (index < path.length) char = path[index];
|
|
74
|
+
else if (char === "/") break;
|
|
75
|
+
else char = "/";
|
|
76
|
+
if (char === "/") {
|
|
77
|
+
if (lastSlash === index - 1 || dots === 1);
|
|
78
|
+
else if (dots === 2) {
|
|
79
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
80
|
+
if (res.length > 2) {
|
|
81
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
82
|
+
if (lastSlashIndex === -1) {
|
|
83
|
+
res = "";
|
|
84
|
+
lastSegmentLength = 0;
|
|
85
|
+
} else {
|
|
86
|
+
res = res.slice(0, lastSlashIndex);
|
|
87
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
88
|
+
}
|
|
89
|
+
lastSlash = index;
|
|
90
|
+
dots = 0;
|
|
91
|
+
continue;
|
|
92
|
+
} else if (res.length > 0) {
|
|
93
|
+
res = "";
|
|
94
|
+
lastSegmentLength = 0;
|
|
95
|
+
lastSlash = index;
|
|
96
|
+
dots = 0;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (allowAboveRoot) {
|
|
101
|
+
res += res.length > 0 ? "/.." : "..";
|
|
102
|
+
lastSegmentLength = 2;
|
|
103
|
+
}
|
|
104
|
+
} else {
|
|
105
|
+
if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
|
|
106
|
+
else res = path.slice(lastSlash + 1, index);
|
|
107
|
+
lastSegmentLength = index - lastSlash - 1;
|
|
108
|
+
}
|
|
109
|
+
lastSlash = index;
|
|
110
|
+
dots = 0;
|
|
111
|
+
} else if (char === "." && dots !== -1) ++dots;
|
|
112
|
+
else dots = -1;
|
|
113
|
+
}
|
|
114
|
+
return res;
|
|
115
|
+
}
|
|
116
|
+
const isAbsolute$1 = function(p) {
|
|
117
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
118
|
+
};
|
|
119
|
+
const relative = function(from, to) {
|
|
120
|
+
const _from = resolve$1(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
121
|
+
const _to = resolve$1(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
122
|
+
if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) return _to.join("/");
|
|
123
|
+
const _fromCopy = [..._from];
|
|
124
|
+
for (const segment of _fromCopy) {
|
|
125
|
+
if (_to[0] !== segment) break;
|
|
126
|
+
_from.shift();
|
|
127
|
+
_to.shift();
|
|
128
|
+
}
|
|
129
|
+
return [..._from.map(() => ".."), ..._to].join("/");
|
|
130
|
+
};
|
|
131
|
+
const dirname$1 = function(p) {
|
|
132
|
+
const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
133
|
+
if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) segments[0] += "/";
|
|
134
|
+
return segments.join("/") || (isAbsolute$1(p) ? "/" : ".");
|
|
135
|
+
};
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region ../../node_modules/.pnpm/smol-toml@1.6.0/node_modules/smol-toml/dist/error.js
|
|
138
|
+
/*!
|
|
139
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
140
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
141
|
+
*
|
|
142
|
+
* Redistribution and use in source and binary forms, with or without
|
|
143
|
+
* modification, are permitted provided that the following conditions are met:
|
|
144
|
+
*
|
|
145
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
146
|
+
* list of conditions and the following disclaimer.
|
|
147
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
148
|
+
* this list of conditions and the following disclaimer in the
|
|
149
|
+
* documentation and/or other materials provided with the distribution.
|
|
150
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
151
|
+
* may be used to endorse or promote products derived from this software without
|
|
152
|
+
* specific prior written permission.
|
|
153
|
+
*
|
|
154
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
155
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
156
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
157
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
158
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
159
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
160
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
161
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
162
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
163
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
164
|
+
*/
|
|
165
|
+
function getLineColFromPtr(string, ptr) {
|
|
166
|
+
let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
|
|
167
|
+
return [lines.length, lines.pop().length + 1];
|
|
168
|
+
}
|
|
169
|
+
function makeCodeBlock(string, line, column) {
|
|
170
|
+
let lines = string.split(/\r\n|\n|\r/g);
|
|
171
|
+
let codeblock = "";
|
|
172
|
+
let numberLen = (Math.log10(line + 1) | 0) + 1;
|
|
173
|
+
for (let i = line - 1; i <= line + 1; i++) {
|
|
174
|
+
let l = lines[i - 1];
|
|
175
|
+
if (!l) continue;
|
|
176
|
+
codeblock += i.toString().padEnd(numberLen, " ");
|
|
177
|
+
codeblock += ": ";
|
|
178
|
+
codeblock += l;
|
|
179
|
+
codeblock += "\n";
|
|
180
|
+
if (i === line) {
|
|
181
|
+
codeblock += " ".repeat(numberLen + column + 2);
|
|
182
|
+
codeblock += "^\n";
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return codeblock;
|
|
186
|
+
}
|
|
187
|
+
var TomlError = class extends Error {
|
|
188
|
+
line;
|
|
189
|
+
column;
|
|
190
|
+
codeblock;
|
|
191
|
+
constructor(message, options) {
|
|
192
|
+
const [line, column] = getLineColFromPtr(options.toml, options.ptr);
|
|
193
|
+
const codeblock = makeCodeBlock(options.toml, line, column);
|
|
194
|
+
super(`Invalid TOML document: ${message}\n\n${codeblock}`, options);
|
|
195
|
+
this.line = line;
|
|
196
|
+
this.column = column;
|
|
197
|
+
this.codeblock = codeblock;
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
//#endregion
|
|
201
|
+
//#region ../../node_modules/.pnpm/smol-toml@1.6.0/node_modules/smol-toml/dist/util.js
|
|
202
|
+
/*!
|
|
203
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
204
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
205
|
+
*
|
|
206
|
+
* Redistribution and use in source and binary forms, with or without
|
|
207
|
+
* modification, are permitted provided that the following conditions are met:
|
|
208
|
+
*
|
|
209
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
210
|
+
* list of conditions and the following disclaimer.
|
|
211
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
212
|
+
* this list of conditions and the following disclaimer in the
|
|
213
|
+
* documentation and/or other materials provided with the distribution.
|
|
214
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
215
|
+
* may be used to endorse or promote products derived from this software without
|
|
216
|
+
* specific prior written permission.
|
|
217
|
+
*
|
|
218
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
219
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
220
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
221
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
222
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
223
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
224
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
225
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
226
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
227
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
228
|
+
*/
|
|
229
|
+
function isEscaped(str, ptr) {
|
|
230
|
+
let i = 0;
|
|
231
|
+
while (str[ptr - ++i] === "\\");
|
|
232
|
+
return --i && i % 2;
|
|
233
|
+
}
|
|
234
|
+
function indexOfNewline(str, start = 0, end = str.length) {
|
|
235
|
+
let idx = str.indexOf("\n", start);
|
|
236
|
+
if (str[idx - 1] === "\r") idx--;
|
|
237
|
+
return idx <= end ? idx : -1;
|
|
238
|
+
}
|
|
239
|
+
function skipComment(str, ptr) {
|
|
240
|
+
for (let i = ptr; i < str.length; i++) {
|
|
241
|
+
let c = str[i];
|
|
242
|
+
if (c === "\n") return i;
|
|
243
|
+
if (c === "\r" && str[i + 1] === "\n") return i + 1;
|
|
244
|
+
if (c < " " && c !== " " || c === "") throw new TomlError("control characters are not allowed in comments", {
|
|
245
|
+
toml: str,
|
|
246
|
+
ptr
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
return str.length;
|
|
250
|
+
}
|
|
251
|
+
function skipVoid(str, ptr, banNewLines, banComments) {
|
|
252
|
+
let c;
|
|
253
|
+
while ((c = str[ptr]) === " " || c === " " || !banNewLines && (c === "\n" || c === "\r" && str[ptr + 1] === "\n")) ptr++;
|
|
254
|
+
return banComments || c !== "#" ? ptr : skipVoid(str, skipComment(str, ptr), banNewLines);
|
|
255
|
+
}
|
|
256
|
+
function skipUntil(str, ptr, sep, end, banNewLines = false) {
|
|
257
|
+
if (!end) {
|
|
258
|
+
ptr = indexOfNewline(str, ptr);
|
|
259
|
+
return ptr < 0 ? str.length : ptr;
|
|
260
|
+
}
|
|
261
|
+
for (let i = ptr; i < str.length; i++) {
|
|
262
|
+
let c = str[i];
|
|
263
|
+
if (c === "#") i = indexOfNewline(str, i);
|
|
264
|
+
else if (c === sep) return i + 1;
|
|
265
|
+
else if (c === end || banNewLines && (c === "\n" || c === "\r" && str[i + 1] === "\n")) return i;
|
|
266
|
+
}
|
|
267
|
+
throw new TomlError("cannot find end of structure", {
|
|
268
|
+
toml: str,
|
|
269
|
+
ptr
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
function getStringEnd(str, seek) {
|
|
273
|
+
let first = str[seek];
|
|
274
|
+
let target = first === str[seek + 1] && str[seek + 1] === str[seek + 2] ? str.slice(seek, seek + 3) : first;
|
|
275
|
+
seek += target.length - 1;
|
|
276
|
+
do
|
|
277
|
+
seek = str.indexOf(target, ++seek);
|
|
278
|
+
while (seek > -1 && first !== "'" && isEscaped(str, seek));
|
|
279
|
+
if (seek > -1) {
|
|
280
|
+
seek += target.length;
|
|
281
|
+
if (target.length > 1) {
|
|
282
|
+
if (str[seek] === first) seek++;
|
|
283
|
+
if (str[seek] === first) seek++;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return seek;
|
|
287
|
+
}
|
|
288
|
+
//#endregion
|
|
289
|
+
//#region ../../node_modules/.pnpm/smol-toml@1.6.0/node_modules/smol-toml/dist/date.js
|
|
290
|
+
/*!
|
|
291
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
292
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
293
|
+
*
|
|
294
|
+
* Redistribution and use in source and binary forms, with or without
|
|
295
|
+
* modification, are permitted provided that the following conditions are met:
|
|
296
|
+
*
|
|
297
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
298
|
+
* list of conditions and the following disclaimer.
|
|
299
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
300
|
+
* this list of conditions and the following disclaimer in the
|
|
301
|
+
* documentation and/or other materials provided with the distribution.
|
|
302
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
303
|
+
* may be used to endorse or promote products derived from this software without
|
|
304
|
+
* specific prior written permission.
|
|
305
|
+
*
|
|
306
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
307
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
308
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
309
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
310
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
311
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
312
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
313
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
314
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
315
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
316
|
+
*/
|
|
317
|
+
let DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
|
|
318
|
+
var TomlDate = class TomlDate extends Date {
|
|
319
|
+
#hasDate = false;
|
|
320
|
+
#hasTime = false;
|
|
321
|
+
#offset = null;
|
|
322
|
+
constructor(date) {
|
|
323
|
+
let hasDate = true;
|
|
324
|
+
let hasTime = true;
|
|
325
|
+
let offset = "Z";
|
|
326
|
+
if (typeof date === "string") {
|
|
327
|
+
let match = date.match(DATE_TIME_RE);
|
|
328
|
+
if (match) {
|
|
329
|
+
if (!match[1]) {
|
|
330
|
+
hasDate = false;
|
|
331
|
+
date = `0000-01-01T${date}`;
|
|
332
|
+
}
|
|
333
|
+
hasTime = !!match[2];
|
|
334
|
+
hasTime && date[10] === " " && (date = date.replace(" ", "T"));
|
|
335
|
+
if (match[2] && +match[2] > 23) date = "";
|
|
336
|
+
else {
|
|
337
|
+
offset = match[3] || null;
|
|
338
|
+
date = date.toUpperCase();
|
|
339
|
+
if (!offset && hasTime) date += "Z";
|
|
340
|
+
}
|
|
341
|
+
} else date = "";
|
|
342
|
+
}
|
|
343
|
+
super(date);
|
|
344
|
+
if (!isNaN(this.getTime())) {
|
|
345
|
+
this.#hasDate = hasDate;
|
|
346
|
+
this.#hasTime = hasTime;
|
|
347
|
+
this.#offset = offset;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
isDateTime() {
|
|
351
|
+
return this.#hasDate && this.#hasTime;
|
|
352
|
+
}
|
|
353
|
+
isLocal() {
|
|
354
|
+
return !this.#hasDate || !this.#hasTime || !this.#offset;
|
|
355
|
+
}
|
|
356
|
+
isDate() {
|
|
357
|
+
return this.#hasDate && !this.#hasTime;
|
|
358
|
+
}
|
|
359
|
+
isTime() {
|
|
360
|
+
return this.#hasTime && !this.#hasDate;
|
|
361
|
+
}
|
|
362
|
+
isValid() {
|
|
363
|
+
return this.#hasDate || this.#hasTime;
|
|
364
|
+
}
|
|
365
|
+
toISOString() {
|
|
366
|
+
let iso = super.toISOString();
|
|
367
|
+
if (this.isDate()) return iso.slice(0, 10);
|
|
368
|
+
if (this.isTime()) return iso.slice(11, 23);
|
|
369
|
+
if (this.#offset === null) return iso.slice(0, -1);
|
|
370
|
+
if (this.#offset === "Z") return iso;
|
|
371
|
+
let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
|
|
372
|
+
offset = this.#offset[0] === "-" ? offset : -offset;
|
|
373
|
+
return (/* @__PURE__ */ new Date(this.getTime() - offset * 6e4)).toISOString().slice(0, -1) + this.#offset;
|
|
374
|
+
}
|
|
375
|
+
static wrapAsOffsetDateTime(jsDate, offset = "Z") {
|
|
376
|
+
let date = new TomlDate(jsDate);
|
|
377
|
+
date.#offset = offset;
|
|
378
|
+
return date;
|
|
379
|
+
}
|
|
380
|
+
static wrapAsLocalDateTime(jsDate) {
|
|
381
|
+
let date = new TomlDate(jsDate);
|
|
382
|
+
date.#offset = null;
|
|
383
|
+
return date;
|
|
384
|
+
}
|
|
385
|
+
static wrapAsLocalDate(jsDate) {
|
|
386
|
+
let date = new TomlDate(jsDate);
|
|
387
|
+
date.#hasTime = false;
|
|
388
|
+
date.#offset = null;
|
|
389
|
+
return date;
|
|
390
|
+
}
|
|
391
|
+
static wrapAsLocalTime(jsDate) {
|
|
392
|
+
let date = new TomlDate(jsDate);
|
|
393
|
+
date.#hasDate = false;
|
|
394
|
+
date.#offset = null;
|
|
395
|
+
return date;
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
//#endregion
|
|
399
|
+
//#region ../../node_modules/.pnpm/smol-toml@1.6.0/node_modules/smol-toml/dist/primitive.js
|
|
400
|
+
/*!
|
|
401
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
402
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
403
|
+
*
|
|
404
|
+
* Redistribution and use in source and binary forms, with or without
|
|
405
|
+
* modification, are permitted provided that the following conditions are met:
|
|
406
|
+
*
|
|
407
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
408
|
+
* list of conditions and the following disclaimer.
|
|
409
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
410
|
+
* this list of conditions and the following disclaimer in the
|
|
411
|
+
* documentation and/or other materials provided with the distribution.
|
|
412
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
413
|
+
* may be used to endorse or promote products derived from this software without
|
|
414
|
+
* specific prior written permission.
|
|
415
|
+
*
|
|
416
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
417
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
418
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
419
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
420
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
421
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
422
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
423
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
424
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
425
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
426
|
+
*/
|
|
427
|
+
let INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
|
|
428
|
+
let FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
|
|
429
|
+
let LEADING_ZERO = /^[+-]?0[0-9_]/;
|
|
430
|
+
let ESCAPE_REGEX = /^[0-9a-f]{2,8}$/i;
|
|
431
|
+
let ESC_MAP = {
|
|
432
|
+
b: "\b",
|
|
433
|
+
t: " ",
|
|
434
|
+
n: "\n",
|
|
435
|
+
f: "\f",
|
|
436
|
+
r: "\r",
|
|
437
|
+
e: "\x1B",
|
|
438
|
+
"\"": "\"",
|
|
439
|
+
"\\": "\\"
|
|
440
|
+
};
|
|
441
|
+
function parseString(str, ptr = 0, endPtr = str.length) {
|
|
442
|
+
let isLiteral = str[ptr] === "'";
|
|
443
|
+
let isMultiline = str[ptr++] === str[ptr] && str[ptr] === str[ptr + 1];
|
|
444
|
+
if (isMultiline) {
|
|
445
|
+
endPtr -= 2;
|
|
446
|
+
if (str[ptr += 2] === "\r") ptr++;
|
|
447
|
+
if (str[ptr] === "\n") ptr++;
|
|
448
|
+
}
|
|
449
|
+
let tmp = 0;
|
|
450
|
+
let isEscape;
|
|
451
|
+
let parsed = "";
|
|
452
|
+
let sliceStart = ptr;
|
|
453
|
+
while (ptr < endPtr - 1) {
|
|
454
|
+
let c = str[ptr++];
|
|
455
|
+
if (c === "\n" || c === "\r" && str[ptr] === "\n") {
|
|
456
|
+
if (!isMultiline) throw new TomlError("newlines are not allowed in strings", {
|
|
457
|
+
toml: str,
|
|
458
|
+
ptr: ptr - 1
|
|
459
|
+
});
|
|
460
|
+
} else if (c < " " && c !== " " || c === "") throw new TomlError("control characters are not allowed in strings", {
|
|
461
|
+
toml: str,
|
|
462
|
+
ptr: ptr - 1
|
|
463
|
+
});
|
|
464
|
+
if (isEscape) {
|
|
465
|
+
isEscape = false;
|
|
466
|
+
if (c === "x" || c === "u" || c === "U") {
|
|
467
|
+
let code = str.slice(ptr, ptr += c === "x" ? 2 : c === "u" ? 4 : 8);
|
|
468
|
+
if (!ESCAPE_REGEX.test(code)) throw new TomlError("invalid unicode escape", {
|
|
469
|
+
toml: str,
|
|
470
|
+
ptr: tmp
|
|
471
|
+
});
|
|
472
|
+
try {
|
|
473
|
+
parsed += String.fromCodePoint(parseInt(code, 16));
|
|
474
|
+
} catch {
|
|
475
|
+
throw new TomlError("invalid unicode escape", {
|
|
476
|
+
toml: str,
|
|
477
|
+
ptr: tmp
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
} else if (isMultiline && (c === "\n" || c === " " || c === " " || c === "\r")) {
|
|
481
|
+
ptr = skipVoid(str, ptr - 1, true);
|
|
482
|
+
if (str[ptr] !== "\n" && str[ptr] !== "\r") throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
|
|
483
|
+
toml: str,
|
|
484
|
+
ptr: tmp
|
|
485
|
+
});
|
|
486
|
+
ptr = skipVoid(str, ptr);
|
|
487
|
+
} else if (c in ESC_MAP) parsed += ESC_MAP[c];
|
|
488
|
+
else throw new TomlError("unrecognized escape sequence", {
|
|
489
|
+
toml: str,
|
|
490
|
+
ptr: tmp
|
|
491
|
+
});
|
|
492
|
+
sliceStart = ptr;
|
|
493
|
+
} else if (!isLiteral && c === "\\") {
|
|
494
|
+
tmp = ptr - 1;
|
|
495
|
+
isEscape = true;
|
|
496
|
+
parsed += str.slice(sliceStart, tmp);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
return parsed + str.slice(sliceStart, endPtr - 1);
|
|
500
|
+
}
|
|
501
|
+
function parseValue(value, toml, ptr, integersAsBigInt) {
|
|
502
|
+
if (value === "true") return true;
|
|
503
|
+
if (value === "false") return false;
|
|
504
|
+
if (value === "-inf") return -Infinity;
|
|
505
|
+
if (value === "inf" || value === "+inf") return Infinity;
|
|
506
|
+
if (value === "nan" || value === "+nan" || value === "-nan") return NaN;
|
|
507
|
+
if (value === "-0") return integersAsBigInt ? 0n : 0;
|
|
508
|
+
let isInt = INT_REGEX.test(value);
|
|
509
|
+
if (isInt || FLOAT_REGEX.test(value)) {
|
|
510
|
+
if (LEADING_ZERO.test(value)) throw new TomlError("leading zeroes are not allowed", {
|
|
511
|
+
toml,
|
|
512
|
+
ptr
|
|
513
|
+
});
|
|
514
|
+
value = value.replace(/_/g, "");
|
|
515
|
+
let numeric = +value;
|
|
516
|
+
if (isNaN(numeric)) throw new TomlError("invalid number", {
|
|
517
|
+
toml,
|
|
518
|
+
ptr
|
|
519
|
+
});
|
|
520
|
+
if (isInt) {
|
|
521
|
+
if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) throw new TomlError("integer value cannot be represented losslessly", {
|
|
522
|
+
toml,
|
|
523
|
+
ptr
|
|
524
|
+
});
|
|
525
|
+
if (isInt || integersAsBigInt === true) numeric = BigInt(value);
|
|
526
|
+
}
|
|
527
|
+
return numeric;
|
|
528
|
+
}
|
|
529
|
+
const date = new TomlDate(value);
|
|
530
|
+
if (!date.isValid()) throw new TomlError("invalid value", {
|
|
531
|
+
toml,
|
|
532
|
+
ptr
|
|
533
|
+
});
|
|
534
|
+
return date;
|
|
535
|
+
}
|
|
536
|
+
//#endregion
|
|
537
|
+
//#region ../../node_modules/.pnpm/smol-toml@1.6.0/node_modules/smol-toml/dist/extract.js
|
|
538
|
+
/*!
|
|
539
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
540
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
541
|
+
*
|
|
542
|
+
* Redistribution and use in source and binary forms, with or without
|
|
543
|
+
* modification, are permitted provided that the following conditions are met:
|
|
544
|
+
*
|
|
545
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
546
|
+
* list of conditions and the following disclaimer.
|
|
547
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
548
|
+
* this list of conditions and the following disclaimer in the
|
|
549
|
+
* documentation and/or other materials provided with the distribution.
|
|
550
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
551
|
+
* may be used to endorse or promote products derived from this software without
|
|
552
|
+
* specific prior written permission.
|
|
553
|
+
*
|
|
554
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
555
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
556
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
557
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
558
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
559
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
560
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
561
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
562
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
563
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
564
|
+
*/
|
|
565
|
+
function sliceAndTrimEndOf(str, startPtr, endPtr) {
|
|
566
|
+
let value = str.slice(startPtr, endPtr);
|
|
567
|
+
let commentIdx = value.indexOf("#");
|
|
568
|
+
if (commentIdx > -1) {
|
|
569
|
+
skipComment(str, commentIdx);
|
|
570
|
+
value = value.slice(0, commentIdx);
|
|
571
|
+
}
|
|
572
|
+
return [value.trimEnd(), commentIdx];
|
|
573
|
+
}
|
|
574
|
+
function extractValue(str, ptr, end, depth, integersAsBigInt) {
|
|
575
|
+
if (depth === 0) throw new TomlError("document contains excessively nested structures. aborting.", {
|
|
576
|
+
toml: str,
|
|
577
|
+
ptr
|
|
578
|
+
});
|
|
579
|
+
let c = str[ptr];
|
|
580
|
+
if (c === "[" || c === "{") {
|
|
581
|
+
let [value, endPtr] = c === "[" ? parseArray(str, ptr, depth, integersAsBigInt) : parseInlineTable(str, ptr, depth, integersAsBigInt);
|
|
582
|
+
if (end) {
|
|
583
|
+
endPtr = skipVoid(str, endPtr);
|
|
584
|
+
if (str[endPtr] === ",") endPtr++;
|
|
585
|
+
else if (str[endPtr] !== end) throw new TomlError("expected comma or end of structure", {
|
|
586
|
+
toml: str,
|
|
587
|
+
ptr: endPtr
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
return [value, endPtr];
|
|
591
|
+
}
|
|
592
|
+
let endPtr;
|
|
593
|
+
if (c === "\"" || c === "'") {
|
|
594
|
+
endPtr = getStringEnd(str, ptr);
|
|
595
|
+
let parsed = parseString(str, ptr, endPtr);
|
|
596
|
+
if (end) {
|
|
597
|
+
endPtr = skipVoid(str, endPtr);
|
|
598
|
+
if (str[endPtr] && str[endPtr] !== "," && str[endPtr] !== end && str[endPtr] !== "\n" && str[endPtr] !== "\r") throw new TomlError("unexpected character encountered", {
|
|
599
|
+
toml: str,
|
|
600
|
+
ptr: endPtr
|
|
601
|
+
});
|
|
602
|
+
endPtr += +(str[endPtr] === ",");
|
|
603
|
+
}
|
|
604
|
+
return [parsed, endPtr];
|
|
605
|
+
}
|
|
606
|
+
endPtr = skipUntil(str, ptr, ",", end);
|
|
607
|
+
let slice = sliceAndTrimEndOf(str, ptr, endPtr - +(str[endPtr - 1] === ","));
|
|
608
|
+
if (!slice[0]) throw new TomlError("incomplete key-value declaration: no value specified", {
|
|
609
|
+
toml: str,
|
|
610
|
+
ptr
|
|
611
|
+
});
|
|
612
|
+
if (end && slice[1] > -1) {
|
|
613
|
+
endPtr = skipVoid(str, ptr + slice[1]);
|
|
614
|
+
endPtr += +(str[endPtr] === ",");
|
|
615
|
+
}
|
|
616
|
+
return [parseValue(slice[0], str, ptr, integersAsBigInt), endPtr];
|
|
617
|
+
}
|
|
618
|
+
//#endregion
|
|
619
|
+
//#region ../../node_modules/.pnpm/smol-toml@1.6.0/node_modules/smol-toml/dist/struct.js
|
|
620
|
+
/*!
|
|
621
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
622
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
623
|
+
*
|
|
624
|
+
* Redistribution and use in source and binary forms, with or without
|
|
625
|
+
* modification, are permitted provided that the following conditions are met:
|
|
626
|
+
*
|
|
627
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
628
|
+
* list of conditions and the following disclaimer.
|
|
629
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
630
|
+
* this list of conditions and the following disclaimer in the
|
|
631
|
+
* documentation and/or other materials provided with the distribution.
|
|
632
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
633
|
+
* may be used to endorse or promote products derived from this software without
|
|
634
|
+
* specific prior written permission.
|
|
635
|
+
*
|
|
636
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
637
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
638
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
639
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
640
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
641
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
642
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
643
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
644
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
645
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
646
|
+
*/
|
|
647
|
+
let KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
|
|
648
|
+
function parseKey(str, ptr, end = "=") {
|
|
649
|
+
let dot = ptr - 1;
|
|
650
|
+
let parsed = [];
|
|
651
|
+
let endPtr = str.indexOf(end, ptr);
|
|
652
|
+
if (endPtr < 0) throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
653
|
+
toml: str,
|
|
654
|
+
ptr
|
|
655
|
+
});
|
|
656
|
+
do {
|
|
657
|
+
let c = str[ptr = ++dot];
|
|
658
|
+
if (c !== " " && c !== " ") if (c === "\"" || c === "'") {
|
|
659
|
+
if (c === str[ptr + 1] && c === str[ptr + 2]) throw new TomlError("multiline strings are not allowed in keys", {
|
|
660
|
+
toml: str,
|
|
661
|
+
ptr
|
|
662
|
+
});
|
|
663
|
+
let eos = getStringEnd(str, ptr);
|
|
664
|
+
if (eos < 0) throw new TomlError("unfinished string encountered", {
|
|
665
|
+
toml: str,
|
|
666
|
+
ptr
|
|
667
|
+
});
|
|
668
|
+
dot = str.indexOf(".", eos);
|
|
669
|
+
let strEnd = str.slice(eos, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
670
|
+
let newLine = indexOfNewline(strEnd);
|
|
671
|
+
if (newLine > -1) throw new TomlError("newlines are not allowed in keys", {
|
|
672
|
+
toml: str,
|
|
673
|
+
ptr: ptr + dot + newLine
|
|
674
|
+
});
|
|
675
|
+
if (strEnd.trimStart()) throw new TomlError("found extra tokens after the string part", {
|
|
676
|
+
toml: str,
|
|
677
|
+
ptr: eos
|
|
678
|
+
});
|
|
679
|
+
if (endPtr < eos) {
|
|
680
|
+
endPtr = str.indexOf(end, eos);
|
|
681
|
+
if (endPtr < 0) throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
682
|
+
toml: str,
|
|
683
|
+
ptr
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
parsed.push(parseString(str, ptr, eos));
|
|
687
|
+
} else {
|
|
688
|
+
dot = str.indexOf(".", ptr);
|
|
689
|
+
let part = str.slice(ptr, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
690
|
+
if (!KEY_PART_RE.test(part)) throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
|
|
691
|
+
toml: str,
|
|
692
|
+
ptr
|
|
693
|
+
});
|
|
694
|
+
parsed.push(part.trimEnd());
|
|
695
|
+
}
|
|
696
|
+
} while (dot + 1 && dot < endPtr);
|
|
697
|
+
return [parsed, skipVoid(str, endPtr + 1, true, true)];
|
|
698
|
+
}
|
|
699
|
+
function parseInlineTable(str, ptr, depth, integersAsBigInt) {
|
|
700
|
+
let res = {};
|
|
701
|
+
let seen = /* @__PURE__ */ new Set();
|
|
702
|
+
let c;
|
|
703
|
+
ptr++;
|
|
704
|
+
while ((c = str[ptr++]) !== "}" && c) if (c === ",") throw new TomlError("expected value, found comma", {
|
|
705
|
+
toml: str,
|
|
706
|
+
ptr: ptr - 1
|
|
707
|
+
});
|
|
708
|
+
else if (c === "#") ptr = skipComment(str, ptr);
|
|
709
|
+
else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
|
|
710
|
+
let k;
|
|
711
|
+
let t = res;
|
|
712
|
+
let hasOwn = false;
|
|
713
|
+
let [key, keyEndPtr] = parseKey(str, ptr - 1);
|
|
714
|
+
for (let i = 0; i < key.length; i++) {
|
|
715
|
+
if (i) t = hasOwn ? t[k] : t[k] = {};
|
|
716
|
+
k = key[i];
|
|
717
|
+
if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) throw new TomlError("trying to redefine an already defined value", {
|
|
718
|
+
toml: str,
|
|
719
|
+
ptr
|
|
720
|
+
});
|
|
721
|
+
if (!hasOwn && k === "__proto__") Object.defineProperty(t, k, {
|
|
722
|
+
enumerable: true,
|
|
723
|
+
configurable: true,
|
|
724
|
+
writable: true
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
if (hasOwn) throw new TomlError("trying to redefine an already defined value", {
|
|
728
|
+
toml: str,
|
|
729
|
+
ptr
|
|
730
|
+
});
|
|
731
|
+
let [value, valueEndPtr] = extractValue(str, keyEndPtr, "}", depth - 1, integersAsBigInt);
|
|
732
|
+
seen.add(value);
|
|
733
|
+
t[k] = value;
|
|
734
|
+
ptr = valueEndPtr;
|
|
735
|
+
}
|
|
736
|
+
if (!c) throw new TomlError("unfinished table encountered", {
|
|
737
|
+
toml: str,
|
|
738
|
+
ptr
|
|
739
|
+
});
|
|
740
|
+
return [res, ptr];
|
|
741
|
+
}
|
|
742
|
+
function parseArray(str, ptr, depth, integersAsBigInt) {
|
|
743
|
+
let res = [];
|
|
744
|
+
let c;
|
|
745
|
+
ptr++;
|
|
746
|
+
while ((c = str[ptr++]) !== "]" && c) if (c === ",") throw new TomlError("expected value, found comma", {
|
|
747
|
+
toml: str,
|
|
748
|
+
ptr: ptr - 1
|
|
749
|
+
});
|
|
750
|
+
else if (c === "#") ptr = skipComment(str, ptr);
|
|
751
|
+
else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
|
|
752
|
+
let e = extractValue(str, ptr - 1, "]", depth - 1, integersAsBigInt);
|
|
753
|
+
res.push(e[0]);
|
|
754
|
+
ptr = e[1];
|
|
755
|
+
}
|
|
756
|
+
if (!c) throw new TomlError("unfinished array encountered", {
|
|
757
|
+
toml: str,
|
|
758
|
+
ptr
|
|
759
|
+
});
|
|
760
|
+
return [res, ptr];
|
|
761
|
+
}
|
|
762
|
+
//#endregion
|
|
763
|
+
//#region ../../node_modules/.pnpm/smol-toml@1.6.0/node_modules/smol-toml/dist/parse.js
|
|
764
|
+
/*!
|
|
765
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
766
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
767
|
+
*
|
|
768
|
+
* Redistribution and use in source and binary forms, with or without
|
|
769
|
+
* modification, are permitted provided that the following conditions are met:
|
|
770
|
+
*
|
|
771
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
772
|
+
* list of conditions and the following disclaimer.
|
|
773
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
774
|
+
* this list of conditions and the following disclaimer in the
|
|
775
|
+
* documentation and/or other materials provided with the distribution.
|
|
776
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
777
|
+
* may be used to endorse or promote products derived from this software without
|
|
778
|
+
* specific prior written permission.
|
|
779
|
+
*
|
|
780
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
781
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
782
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
783
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
784
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
785
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
786
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
787
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
788
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
789
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
790
|
+
*/
|
|
791
|
+
function peekTable(key, table, meta, type) {
|
|
792
|
+
let t = table;
|
|
793
|
+
let m = meta;
|
|
794
|
+
let k;
|
|
795
|
+
let hasOwn = false;
|
|
796
|
+
let state;
|
|
797
|
+
for (let i = 0; i < key.length; i++) {
|
|
798
|
+
if (i) {
|
|
799
|
+
t = hasOwn ? t[k] : t[k] = {};
|
|
800
|
+
m = (state = m[k]).c;
|
|
801
|
+
if (type === 0 && (state.t === 1 || state.t === 2)) return null;
|
|
802
|
+
if (state.t === 2) {
|
|
803
|
+
let l = t.length - 1;
|
|
804
|
+
t = t[l];
|
|
805
|
+
m = m[l].c;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
k = key[i];
|
|
809
|
+
if ((hasOwn = Object.hasOwn(t, k)) && m[k]?.t === 0 && m[k]?.d) return null;
|
|
810
|
+
if (!hasOwn) {
|
|
811
|
+
if (k === "__proto__") {
|
|
812
|
+
Object.defineProperty(t, k, {
|
|
813
|
+
enumerable: true,
|
|
814
|
+
configurable: true,
|
|
815
|
+
writable: true
|
|
816
|
+
});
|
|
817
|
+
Object.defineProperty(m, k, {
|
|
818
|
+
enumerable: true,
|
|
819
|
+
configurable: true,
|
|
820
|
+
writable: true
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
m[k] = {
|
|
824
|
+
t: i < key.length - 1 && type === 2 ? 3 : type,
|
|
825
|
+
d: false,
|
|
826
|
+
i: 0,
|
|
827
|
+
c: {}
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
state = m[k];
|
|
832
|
+
if (state.t !== type && !(type === 1 && state.t === 3)) return null;
|
|
833
|
+
if (type === 2) {
|
|
834
|
+
if (!state.d) {
|
|
835
|
+
state.d = true;
|
|
836
|
+
t[k] = [];
|
|
837
|
+
}
|
|
838
|
+
t[k].push(t = {});
|
|
839
|
+
state.c[state.i++] = state = {
|
|
840
|
+
t: 1,
|
|
841
|
+
d: false,
|
|
842
|
+
i: 0,
|
|
843
|
+
c: {}
|
|
844
|
+
};
|
|
845
|
+
}
|
|
846
|
+
if (state.d) return null;
|
|
847
|
+
state.d = true;
|
|
848
|
+
if (type === 1) t = hasOwn ? t[k] : t[k] = {};
|
|
849
|
+
else if (type === 0 && hasOwn) return null;
|
|
850
|
+
return [
|
|
851
|
+
k,
|
|
852
|
+
t,
|
|
853
|
+
state.c
|
|
854
|
+
];
|
|
855
|
+
}
|
|
856
|
+
function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
|
|
857
|
+
let res = {};
|
|
858
|
+
let meta = {};
|
|
859
|
+
let tbl = res;
|
|
860
|
+
let m = meta;
|
|
861
|
+
for (let ptr = skipVoid(toml, 0); ptr < toml.length;) {
|
|
862
|
+
if (toml[ptr] === "[") {
|
|
863
|
+
let isTableArray = toml[++ptr] === "[";
|
|
864
|
+
let k = parseKey(toml, ptr += +isTableArray, "]");
|
|
865
|
+
if (isTableArray) {
|
|
866
|
+
if (toml[k[1] - 1] !== "]") throw new TomlError("expected end of table declaration", {
|
|
867
|
+
toml,
|
|
868
|
+
ptr: k[1] - 1
|
|
869
|
+
});
|
|
870
|
+
k[1]++;
|
|
871
|
+
}
|
|
872
|
+
let p = peekTable(k[0], res, meta, isTableArray ? 2 : 1);
|
|
873
|
+
if (!p) throw new TomlError("trying to redefine an already defined table or value", {
|
|
874
|
+
toml,
|
|
875
|
+
ptr
|
|
876
|
+
});
|
|
877
|
+
m = p[2];
|
|
878
|
+
tbl = p[1];
|
|
879
|
+
ptr = k[1];
|
|
880
|
+
} else {
|
|
881
|
+
let k = parseKey(toml, ptr);
|
|
882
|
+
let p = peekTable(k[0], tbl, m, 0);
|
|
883
|
+
if (!p) throw new TomlError("trying to redefine an already defined table or value", {
|
|
884
|
+
toml,
|
|
885
|
+
ptr
|
|
886
|
+
});
|
|
887
|
+
let v = extractValue(toml, k[1], void 0, maxDepth, integersAsBigInt);
|
|
888
|
+
p[1][p[0]] = v[0];
|
|
889
|
+
ptr = v[1];
|
|
890
|
+
}
|
|
891
|
+
ptr = skipVoid(toml, ptr, true);
|
|
892
|
+
if (toml[ptr] && toml[ptr] !== "\n" && toml[ptr] !== "\r") throw new TomlError("each key-value declaration must be followed by an end-of-line", {
|
|
893
|
+
toml,
|
|
894
|
+
ptr
|
|
895
|
+
});
|
|
896
|
+
ptr = skipVoid(toml, ptr);
|
|
897
|
+
}
|
|
898
|
+
return res;
|
|
899
|
+
}
|
|
900
|
+
//#endregion
|
|
901
|
+
//#region ../../node_modules/.pnpm/smol-toml@1.6.0/node_modules/smol-toml/dist/stringify.js
|
|
902
|
+
/*!
|
|
903
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
904
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
905
|
+
*
|
|
906
|
+
* Redistribution and use in source and binary forms, with or without
|
|
907
|
+
* modification, are permitted provided that the following conditions are met:
|
|
908
|
+
*
|
|
909
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
910
|
+
* list of conditions and the following disclaimer.
|
|
911
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
912
|
+
* this list of conditions and the following disclaimer in the
|
|
913
|
+
* documentation and/or other materials provided with the distribution.
|
|
914
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
915
|
+
* may be used to endorse or promote products derived from this software without
|
|
916
|
+
* specific prior written permission.
|
|
917
|
+
*
|
|
918
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
919
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
920
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
921
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
922
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
923
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
924
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
925
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
926
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
927
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
928
|
+
*/
|
|
929
|
+
let BARE_KEY = /^[a-z0-9-_]+$/i;
|
|
930
|
+
function extendedTypeOf(obj) {
|
|
931
|
+
let type = typeof obj;
|
|
932
|
+
if (type === "object") {
|
|
933
|
+
if (Array.isArray(obj)) return "array";
|
|
934
|
+
if (obj instanceof Date) return "date";
|
|
935
|
+
}
|
|
936
|
+
return type;
|
|
937
|
+
}
|
|
938
|
+
function isArrayOfTables(obj) {
|
|
939
|
+
for (let i = 0; i < obj.length; i++) if (extendedTypeOf(obj[i]) !== "object") return false;
|
|
940
|
+
return obj.length != 0;
|
|
941
|
+
}
|
|
942
|
+
function formatString(s) {
|
|
943
|
+
return JSON.stringify(s).replace(/\x7f/g, "\\u007f");
|
|
944
|
+
}
|
|
945
|
+
function stringifyValue(val, type, depth, numberAsFloat) {
|
|
946
|
+
if (depth === 0) throw new Error("Could not stringify the object: maximum object depth exceeded");
|
|
947
|
+
if (type === "number") {
|
|
948
|
+
if (isNaN(val)) return "nan";
|
|
949
|
+
if (val === Infinity) return "inf";
|
|
950
|
+
if (val === -Infinity) return "-inf";
|
|
951
|
+
if (numberAsFloat && Number.isInteger(val)) return val.toFixed(1);
|
|
952
|
+
return val.toString();
|
|
953
|
+
}
|
|
954
|
+
if (type === "bigint" || type === "boolean") return val.toString();
|
|
955
|
+
if (type === "string") return formatString(val);
|
|
956
|
+
if (type === "date") {
|
|
957
|
+
if (isNaN(val.getTime())) throw new TypeError("cannot serialize invalid date");
|
|
958
|
+
return val.toISOString();
|
|
959
|
+
}
|
|
960
|
+
if (type === "object") return stringifyInlineTable(val, depth, numberAsFloat);
|
|
961
|
+
if (type === "array") return stringifyArray(val, depth, numberAsFloat);
|
|
962
|
+
}
|
|
963
|
+
function stringifyInlineTable(obj, depth, numberAsFloat) {
|
|
964
|
+
let keys = Object.keys(obj);
|
|
965
|
+
if (keys.length === 0) return "{}";
|
|
966
|
+
let res = "{ ";
|
|
967
|
+
for (let i = 0; i < keys.length; i++) {
|
|
968
|
+
let k = keys[i];
|
|
969
|
+
if (i) res += ", ";
|
|
970
|
+
res += BARE_KEY.test(k) ? k : formatString(k);
|
|
971
|
+
res += " = ";
|
|
972
|
+
res += stringifyValue(obj[k], extendedTypeOf(obj[k]), depth - 1, numberAsFloat);
|
|
973
|
+
}
|
|
974
|
+
return res + " }";
|
|
975
|
+
}
|
|
976
|
+
function stringifyArray(array, depth, numberAsFloat) {
|
|
977
|
+
if (array.length === 0) return "[]";
|
|
978
|
+
let res = "[ ";
|
|
979
|
+
for (let i = 0; i < array.length; i++) {
|
|
980
|
+
if (i) res += ", ";
|
|
981
|
+
if (array[i] === null || array[i] === void 0) throw new TypeError("arrays cannot contain null or undefined values");
|
|
982
|
+
res += stringifyValue(array[i], extendedTypeOf(array[i]), depth - 1, numberAsFloat);
|
|
983
|
+
}
|
|
984
|
+
return res + " ]";
|
|
985
|
+
}
|
|
986
|
+
function stringifyArrayTable(array, key, depth, numberAsFloat) {
|
|
987
|
+
if (depth === 0) throw new Error("Could not stringify the object: maximum object depth exceeded");
|
|
988
|
+
let res = "";
|
|
989
|
+
for (let i = 0; i < array.length; i++) {
|
|
990
|
+
res += `${res && "\n"}[[${key}]]\n`;
|
|
991
|
+
res += stringifyTable(0, array[i], key, depth, numberAsFloat);
|
|
992
|
+
}
|
|
993
|
+
return res;
|
|
994
|
+
}
|
|
995
|
+
function stringifyTable(tableKey, obj, prefix, depth, numberAsFloat) {
|
|
996
|
+
if (depth === 0) throw new Error("Could not stringify the object: maximum object depth exceeded");
|
|
997
|
+
let preamble = "";
|
|
998
|
+
let tables = "";
|
|
999
|
+
let keys = Object.keys(obj);
|
|
1000
|
+
for (let i = 0; i < keys.length; i++) {
|
|
1001
|
+
let k = keys[i];
|
|
1002
|
+
if (obj[k] !== null && obj[k] !== void 0) {
|
|
1003
|
+
let type = extendedTypeOf(obj[k]);
|
|
1004
|
+
if (type === "symbol" || type === "function") throw new TypeError(`cannot serialize values of type '${type}'`);
|
|
1005
|
+
let key = BARE_KEY.test(k) ? k : formatString(k);
|
|
1006
|
+
if (type === "array" && isArrayOfTables(obj[k])) tables += (tables && "\n") + stringifyArrayTable(obj[k], prefix ? `${prefix}.${key}` : key, depth - 1, numberAsFloat);
|
|
1007
|
+
else if (type === "object") {
|
|
1008
|
+
let tblKey = prefix ? `${prefix}.${key}` : key;
|
|
1009
|
+
tables += (tables && "\n") + stringifyTable(tblKey, obj[k], tblKey, depth - 1, numberAsFloat);
|
|
1010
|
+
} else {
|
|
1011
|
+
preamble += key;
|
|
1012
|
+
preamble += " = ";
|
|
1013
|
+
preamble += stringifyValue(obj[k], type, depth, numberAsFloat);
|
|
1014
|
+
preamble += "\n";
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
if (tableKey && (preamble || !tables)) preamble = preamble ? `[${tableKey}]\n${preamble}` : `[${tableKey}]`;
|
|
1019
|
+
return preamble && tables ? `${preamble}\n${tables}` : preamble || tables;
|
|
1020
|
+
}
|
|
1021
|
+
function stringify(obj, { maxDepth = 1e3, numbersAsFloat = false } = {}) {
|
|
1022
|
+
if (extendedTypeOf(obj) !== "object") throw new TypeError("stringify can only be called with an object");
|
|
1023
|
+
let str = stringifyTable(0, obj, "", maxDepth, numbersAsFloat);
|
|
1024
|
+
if (str[str.length - 1] !== "\n") return str + "\n";
|
|
1025
|
+
return str;
|
|
1026
|
+
}
|
|
1027
|
+
//#endregion
|
|
1028
|
+
//#region ../shared/src/mcp-core/ide-detector/index.ts
|
|
1029
|
+
const DEFAULT_SETTINGS_FILE = "mcp.json";
|
|
1030
|
+
function getSupportedIDEs() {
|
|
1031
|
+
return [
|
|
1032
|
+
{
|
|
1033
|
+
id: "code",
|
|
1034
|
+
brand: "VS Code",
|
|
1035
|
+
detect: {
|
|
1036
|
+
darwin: (env) => isCommandAvailable("code", env),
|
|
1037
|
+
linux: (env) => isCommandAvailable("code", env),
|
|
1038
|
+
win32: (env) => isCommandAvailable("code", env)
|
|
1039
|
+
},
|
|
1040
|
+
settingsDir: {
|
|
1041
|
+
darwin: () => join$1(homedir(), "Library", "Application Support", "Code", "User"),
|
|
1042
|
+
linux: () => join$1(homedir(), ".config", "Code", "User"),
|
|
1043
|
+
win32: (env) => join$1(requiredEnv(env, "APPDATA"), "Code", "User")
|
|
1044
|
+
}
|
|
1045
|
+
},
|
|
1046
|
+
{
|
|
1047
|
+
id: "code-insiders",
|
|
1048
|
+
brand: "VS Code Insiders",
|
|
1049
|
+
detect: {
|
|
1050
|
+
darwin: (env) => isCommandAvailable("code-insiders", env),
|
|
1051
|
+
linux: (env) => isCommandAvailable("code-insiders", env),
|
|
1052
|
+
win32: (env) => isCommandAvailable("code-insiders", env)
|
|
1053
|
+
},
|
|
1054
|
+
settingsDir: {
|
|
1055
|
+
darwin: () => join$1(homedir(), "Library", "Application Support", "Code - Insiders", "User"),
|
|
1056
|
+
linux: () => join$1(homedir(), ".config", "Code - Insiders", "User"),
|
|
1057
|
+
win32: (env) => join$1(requiredEnv(env, "APPDATA"), "Code - Insiders", "User")
|
|
1058
|
+
}
|
|
1059
|
+
},
|
|
1060
|
+
{
|
|
1061
|
+
id: "cursor",
|
|
1062
|
+
brand: "Cursor",
|
|
1063
|
+
detect: {
|
|
1064
|
+
darwin: (env) => isCommandAvailable("cursor", env),
|
|
1065
|
+
linux: (env) => isCommandAvailable("cursor", env),
|
|
1066
|
+
win32: (env) => isCommandAvailable("cursor", env)
|
|
1067
|
+
},
|
|
1068
|
+
settingsDir: {
|
|
1069
|
+
darwin: () => join$1(homedir(), "Library", "Application Support", "Cursor", "User"),
|
|
1070
|
+
linux: () => join$1(homedir(), ".config", "Cursor", "User"),
|
|
1071
|
+
win32: (env) => join$1(requiredEnv(env, "APPDATA"), "Cursor", "User")
|
|
1072
|
+
}
|
|
1073
|
+
},
|
|
1074
|
+
{
|
|
1075
|
+
id: "windsurf",
|
|
1076
|
+
brand: "Windsurf",
|
|
1077
|
+
detect: {
|
|
1078
|
+
darwin: (env) => isCommandAvailable("windsurf", env),
|
|
1079
|
+
linux: (env) => isCommandAvailable("windsurf", env),
|
|
1080
|
+
win32: (env) => isCommandAvailable("windsurf", env)
|
|
1081
|
+
},
|
|
1082
|
+
settingsDir: {
|
|
1083
|
+
darwin: () => join$1(homedir(), "Library", "Application Support", "Windsurf", "User"),
|
|
1084
|
+
linux: () => join$1(homedir(), ".config", "Windsurf", "User"),
|
|
1085
|
+
win32: (env) => join$1(requiredEnv(env, "APPDATA"), "Windsurf", "User")
|
|
1086
|
+
}
|
|
1087
|
+
},
|
|
1088
|
+
{
|
|
1089
|
+
id: "trae",
|
|
1090
|
+
brand: "Trae",
|
|
1091
|
+
detect: {
|
|
1092
|
+
darwin: (env) => isCommandAvailable("trae", env),
|
|
1093
|
+
linux: (env) => isCommandAvailable("trae", env),
|
|
1094
|
+
win32: (env) => isCommandAvailable("trae", env)
|
|
1095
|
+
},
|
|
1096
|
+
settingsDir: {
|
|
1097
|
+
darwin: () => join$1(homedir(), "Library", "Application Support", "Trae", "User"),
|
|
1098
|
+
linux: () => join$1(homedir(), ".config", "Trae", "User"),
|
|
1099
|
+
win32: (env) => join$1(requiredEnv(env, "APPDATA"), "Trae", "User")
|
|
1100
|
+
}
|
|
1101
|
+
},
|
|
1102
|
+
{
|
|
1103
|
+
id: "claude",
|
|
1104
|
+
brand: "Claude Desktop",
|
|
1105
|
+
detect: {
|
|
1106
|
+
darwin: () => pathExists(join$1("/Applications", "Claude.app")),
|
|
1107
|
+
win32: (env) => windowsAppExists("claude", env)
|
|
1108
|
+
},
|
|
1109
|
+
settingsDir: {
|
|
1110
|
+
darwin: () => join$1(homedir(), "Library", "Application Support", "Claude"),
|
|
1111
|
+
win32: (env) => join$1(requiredEnv(env, "APPDATA"), "Claude")
|
|
1112
|
+
},
|
|
1113
|
+
settingsFile: "claude_desktop_config.json"
|
|
1114
|
+
},
|
|
1115
|
+
{
|
|
1116
|
+
id: "claude-code",
|
|
1117
|
+
brand: "Claude Code",
|
|
1118
|
+
detect: {
|
|
1119
|
+
darwin: (env) => isCommandAvailable("claude", env),
|
|
1120
|
+
linux: (env) => isCommandAvailable("claude", env),
|
|
1121
|
+
win32: (env) => isCommandAvailable("claude", env)
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
];
|
|
1125
|
+
}
|
|
1126
|
+
async function detectIDEs(options = {}) {
|
|
1127
|
+
const platform = options.platform ?? process.platform;
|
|
1128
|
+
const env = options.env ?? process.env;
|
|
1129
|
+
const ides = getSupportedIDEs();
|
|
1130
|
+
return await Promise.all(ides.map(async (ide) => {
|
|
1131
|
+
const detected = await (ide.detect?.[platform]?.(env) ?? Promise.resolve(false));
|
|
1132
|
+
const settingsDir = ide.settingsDir?.[platform]?.(env);
|
|
1133
|
+
const settingsFile = resolveSettingsFile(ide, platform);
|
|
1134
|
+
return {
|
|
1135
|
+
id: ide.id,
|
|
1136
|
+
brand: ide.brand,
|
|
1137
|
+
detected,
|
|
1138
|
+
settingsDir,
|
|
1139
|
+
settingsFile
|
|
1140
|
+
};
|
|
1141
|
+
}));
|
|
1142
|
+
}
|
|
1143
|
+
function resolveSettingsFile(ide, platform) {
|
|
1144
|
+
if (typeof ide.settingsFile === "string") return ide.settingsFile;
|
|
1145
|
+
if (typeof ide.settingsFile === "object") return ide.settingsFile[platform] ?? "mcp.json";
|
|
1146
|
+
if (ide.settingsDir) return DEFAULT_SETTINGS_FILE;
|
|
1147
|
+
}
|
|
1148
|
+
function requiredEnv(env, key) {
|
|
1149
|
+
const v = env[key] ?? process.env[key];
|
|
1150
|
+
if (!v) return "";
|
|
1151
|
+
return v;
|
|
1152
|
+
}
|
|
1153
|
+
async function pathExists(path) {
|
|
1154
|
+
try {
|
|
1155
|
+
await access(path, constants.F_OK);
|
|
1156
|
+
return true;
|
|
1157
|
+
} catch {
|
|
1158
|
+
return false;
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
async function isCommandAvailable(command, env) {
|
|
1162
|
+
const platform = process.platform;
|
|
1163
|
+
const pathEntries = (env.PATH ?? process.env.PATH ?? "").split(delimiter).filter(Boolean);
|
|
1164
|
+
const extensions = platform === "win32" ? (env.PATHEXT ?? process.env.PATHEXT ?? ".EXE;.CMD;.BAT;.COM").split(";").filter(Boolean) : [""];
|
|
1165
|
+
for (const base of pathEntries) for (const ext of extensions) if (await pathExists(join$1(base, platform === "win32" ? `${command}${ext}` : command))) return true;
|
|
1166
|
+
return false;
|
|
1167
|
+
}
|
|
1168
|
+
async function windowsAppExists(programName, env) {
|
|
1169
|
+
const dirs = [
|
|
1170
|
+
env.LOCALAPPDATA,
|
|
1171
|
+
env.ProgramFiles,
|
|
1172
|
+
env["ProgramFiles(x86)"]
|
|
1173
|
+
].filter(Boolean);
|
|
1174
|
+
const target = `${programName}.exe`.toLowerCase();
|
|
1175
|
+
for (const dir of dirs) if (await findFileRecursive(dir, target, 4)) return true;
|
|
1176
|
+
return false;
|
|
1177
|
+
}
|
|
1178
|
+
async function findFileRecursive(startPath, fileNameLower, depth) {
|
|
1179
|
+
if (depth < 0) return false;
|
|
1180
|
+
let entries;
|
|
1181
|
+
try {
|
|
1182
|
+
entries = await readdir(startPath);
|
|
1183
|
+
} catch {
|
|
1184
|
+
return false;
|
|
1185
|
+
}
|
|
1186
|
+
for (const entry of entries) {
|
|
1187
|
+
const full = join$1(startPath, entry);
|
|
1188
|
+
if (entry.toLowerCase() === fileNameLower) return true;
|
|
1189
|
+
try {
|
|
1190
|
+
if ((await stat(full)).isDirectory() && await findFileRecursive(full, fileNameLower, depth - 1)) return true;
|
|
1191
|
+
} catch {
|
|
1192
|
+
continue;
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
return false;
|
|
1196
|
+
}
|
|
1197
|
+
//#endregion
|
|
1198
|
+
//#region ../shared/src/mcp-core/ide-config-writer/index.ts
|
|
1199
|
+
const BEARER_PREFIX_RE = /^Bearer\s+/i;
|
|
1200
|
+
const SSE_PATH_RE = /\/sse(\/|$)/i;
|
|
1201
|
+
function resolveRootKey(ideId) {
|
|
1202
|
+
if (ideId === "code" || ideId === "code-insiders" || ideId === "copilot" || ideId === "cline" || ideId === "continue") return "servers";
|
|
1203
|
+
if (ideId === "crush") return "mcp";
|
|
1204
|
+
if (ideId === "opencode") return "mcp";
|
|
1205
|
+
if (ideId === "zed") return "context_servers";
|
|
1206
|
+
return "mcpServers";
|
|
1207
|
+
}
|
|
1208
|
+
async function removeFromJsonConfig(ideId, target, serverId, existingText) {
|
|
1209
|
+
const existing = safeParseJson(existingText);
|
|
1210
|
+
if (!existing || typeof existing !== "object" || Array.isArray(existing)) return false;
|
|
1211
|
+
const rootKey = resolveRootKey(ideId);
|
|
1212
|
+
const record = existing;
|
|
1213
|
+
if (record[rootKey] && typeof record[rootKey] === "object" && record[rootKey][serverId]) {
|
|
1214
|
+
delete record[rootKey][serverId];
|
|
1215
|
+
if (Object.keys(record[rootKey]).length === 0) delete record[rootKey];
|
|
1216
|
+
await writeFile(target, `${JSON.stringify(record, null, 2)}\n`);
|
|
1217
|
+
return true;
|
|
1218
|
+
}
|
|
1219
|
+
return false;
|
|
1220
|
+
}
|
|
1221
|
+
async function removeFromTomlConfig(ideId, target, serverId, existingText) {
|
|
1222
|
+
const existing = safeParseToml(existingText);
|
|
1223
|
+
if (!existing || typeof existing !== "object" || Array.isArray(existing)) return false;
|
|
1224
|
+
if (ideId === "mistralvibe") {
|
|
1225
|
+
const config = existing;
|
|
1226
|
+
if (Array.isArray(config.mcp_servers)) {
|
|
1227
|
+
const filtered = config.mcp_servers.filter((s) => s?.name !== serverId);
|
|
1228
|
+
if (filtered.length !== config.mcp_servers.length) {
|
|
1229
|
+
config.mcp_servers = filtered;
|
|
1230
|
+
if (filtered.length === 0) delete config.mcp_servers;
|
|
1231
|
+
await writeFile(target, stringify(config));
|
|
1232
|
+
return true;
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
return false;
|
|
1236
|
+
}
|
|
1237
|
+
if (ideId === "openhands") {
|
|
1238
|
+
const config = existing;
|
|
1239
|
+
let changed = false;
|
|
1240
|
+
if (config.mcp?.stdio_servers) {
|
|
1241
|
+
const filtered = config.mcp.stdio_servers.filter((s) => s.name !== serverId);
|
|
1242
|
+
if (filtered.length !== config.mcp.stdio_servers.length) {
|
|
1243
|
+
config.mcp.stdio_servers = filtered;
|
|
1244
|
+
changed = true;
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
if (changed) {
|
|
1248
|
+
await writeFile(target, stringify(config));
|
|
1249
|
+
return true;
|
|
1250
|
+
}
|
|
1251
|
+
return false;
|
|
1252
|
+
}
|
|
1253
|
+
const record = existing;
|
|
1254
|
+
if (record.mcp_servers && typeof record.mcp_servers === "object" && record.mcp_servers[serverId]) {
|
|
1255
|
+
delete record.mcp_servers[serverId];
|
|
1256
|
+
if (Object.keys(record.mcp_servers).length === 0) delete record.mcp_servers;
|
|
1257
|
+
await writeFile(target, stringify(record));
|
|
1258
|
+
return true;
|
|
1259
|
+
}
|
|
1260
|
+
return false;
|
|
1261
|
+
}
|
|
1262
|
+
async function removeIdeMcpConfig(options) {
|
|
1263
|
+
const ideId = typeof options.ide === "string" ? options.ide : options.ide.id;
|
|
1264
|
+
const target = options.targetFilePath ?? await resolveDefaultConfigPath(options.ide);
|
|
1265
|
+
if (ideId === "claude-code" || !target) return false;
|
|
1266
|
+
const existingText = await tryReadFile(target);
|
|
1267
|
+
if (!existingText) return false;
|
|
1268
|
+
if (ideId === "crush" || ideId === "opencode" || ideId === "zed" || target.endsWith(".json")) return await removeFromJsonConfig(ideId, target, options.serverId, existingText);
|
|
1269
|
+
if (target.endsWith(".toml")) return await removeFromTomlConfig(ideId, target, options.serverId, existingText);
|
|
1270
|
+
return false;
|
|
1271
|
+
}
|
|
1272
|
+
async function writeIdeMcpConfig(options) {
|
|
1273
|
+
const ideId = typeof options.ide === "string" ? options.ide : options.ide.id;
|
|
1274
|
+
const target = options.targetFilePath ?? await resolveDefaultConfigPath(options.ide);
|
|
1275
|
+
if (ideId === "claude-code" && !options.targetFilePath) {
|
|
1276
|
+
const command = buildClaudeCodeCommand(options.server);
|
|
1277
|
+
if (!command) return {
|
|
1278
|
+
kind: "skipped",
|
|
1279
|
+
ide: ideId,
|
|
1280
|
+
reason: "Unsupported server config for this IDE"
|
|
1281
|
+
};
|
|
1282
|
+
return {
|
|
1283
|
+
kind: "command",
|
|
1284
|
+
ide: ideId,
|
|
1285
|
+
command
|
|
1286
|
+
};
|
|
1287
|
+
}
|
|
1288
|
+
if (!target) return {
|
|
1289
|
+
kind: "skipped",
|
|
1290
|
+
ide: ideId,
|
|
1291
|
+
reason: "No config target for this IDE"
|
|
1292
|
+
};
|
|
1293
|
+
const mode = options.mode ?? "merge";
|
|
1294
|
+
const { created, updated } = await writeNativeConfig({
|
|
1295
|
+
ide: ideId,
|
|
1296
|
+
server: options.server,
|
|
1297
|
+
filePath: target,
|
|
1298
|
+
mode
|
|
1299
|
+
});
|
|
1300
|
+
return {
|
|
1301
|
+
kind: "written",
|
|
1302
|
+
ide: ideId,
|
|
1303
|
+
filePath: target,
|
|
1304
|
+
created,
|
|
1305
|
+
updated
|
|
1306
|
+
};
|
|
1307
|
+
}
|
|
1308
|
+
function buildIdeConfigDocument(ide, server) {
|
|
1309
|
+
return { [ide === "code" || ide === "code-insiders" || ide === "copilot" || ide === "cline" || ide === "continue" ? "servers" : "mcpServers"]: { [server.id]: toRulerLikeServerDef(server) } };
|
|
1310
|
+
}
|
|
1311
|
+
function buildClaudeCodeCommand(server) {
|
|
1312
|
+
if (server.connection.transport !== "http") return null;
|
|
1313
|
+
const args = [
|
|
1314
|
+
"mcp",
|
|
1315
|
+
"add",
|
|
1316
|
+
"--transport",
|
|
1317
|
+
"http",
|
|
1318
|
+
"--scope",
|
|
1319
|
+
"user",
|
|
1320
|
+
server.id,
|
|
1321
|
+
server.connection.url
|
|
1322
|
+
];
|
|
1323
|
+
if (server.connection.headers?.Authorization) args.push("--header", `Authorization:Bearer ${server.connection.headers.Authorization.replace(BEARER_PREFIX_RE, "")}`);
|
|
1324
|
+
return `claude ${args.map((a) => a.includes(":") || a.includes(" ") ? JSON.stringify(a) : a).join(" ")}`;
|
|
1325
|
+
}
|
|
1326
|
+
async function resolveDefaultConfigPath(ide) {
|
|
1327
|
+
const ideId = typeof ide === "string" ? ide : ide.id;
|
|
1328
|
+
if (typeof ide !== "string" && ide.settingsDir) {
|
|
1329
|
+
const fileName = ide.settingsFile ?? "mcp.json";
|
|
1330
|
+
return join$1(ide.settingsDir, fileName);
|
|
1331
|
+
}
|
|
1332
|
+
const record = getSupportedIDEs().find((i) => i.id === ideId);
|
|
1333
|
+
if (!record) return null;
|
|
1334
|
+
const platform = process.platform;
|
|
1335
|
+
const settingsDir = record.settingsDir?.[platform]?.(process.env);
|
|
1336
|
+
const settingsFile = typeof record.settingsFile === "string" ? record.settingsFile : record.settingsFile?.[platform] ?? (settingsDir ? "mcp.json" : void 0);
|
|
1337
|
+
if (!settingsDir || !settingsFile) return null;
|
|
1338
|
+
return join$1(settingsDir, settingsFile);
|
|
1339
|
+
}
|
|
1340
|
+
async function writeNativeConfig(options) {
|
|
1341
|
+
if (options.ide === "crush") {
|
|
1342
|
+
const next = buildCrushJsonDocument(options.server);
|
|
1343
|
+
return await writeJsonConfig(options.filePath, next, options.mode);
|
|
1344
|
+
}
|
|
1345
|
+
if (options.ide === "openhands") return await writeOpenHandsTomlConfig(options.filePath, options.server, options.mode);
|
|
1346
|
+
if (options.ide === "mistralvibe") return await writeVibeTomlConfig(options.filePath, options.server, options.mode);
|
|
1347
|
+
if (options.ide === "codex" || options.filePath.endsWith(".toml")) {
|
|
1348
|
+
const next = buildCodexTomlDocument(options.server);
|
|
1349
|
+
return await writeTomlConfig(options.filePath, next, options.mode);
|
|
1350
|
+
}
|
|
1351
|
+
if (options.ide === "opencode") {
|
|
1352
|
+
const next = buildOpenCodeJsonDocument(options.server);
|
|
1353
|
+
return await writeJsonConfig(options.filePath, next, options.mode);
|
|
1354
|
+
}
|
|
1355
|
+
if (options.ide === "zed") {
|
|
1356
|
+
const next = buildZedJsonDocument(options.server);
|
|
1357
|
+
return await writeJsonConfig(options.filePath, next, options.mode);
|
|
1358
|
+
}
|
|
1359
|
+
const next = buildIdeConfigDocument(options.ide, options.server);
|
|
1360
|
+
return await writeJsonConfig(options.filePath, next, options.mode);
|
|
1361
|
+
}
|
|
1362
|
+
function buildCrushJsonDocument(server) {
|
|
1363
|
+
if (server.connection.transport === "http") {
|
|
1364
|
+
const type = SSE_PATH_RE.test(server.connection.url) ? "sse" : "http";
|
|
1365
|
+
return { mcp: { [server.id]: {
|
|
1366
|
+
type,
|
|
1367
|
+
url: server.connection.url,
|
|
1368
|
+
headers: server.connection.headers
|
|
1369
|
+
} } };
|
|
1370
|
+
}
|
|
1371
|
+
return { mcp: { [server.id]: {
|
|
1372
|
+
type: "stdio",
|
|
1373
|
+
command: server.connection.command,
|
|
1374
|
+
args: server.connection.args,
|
|
1375
|
+
env: server.connection.env
|
|
1376
|
+
} } };
|
|
1377
|
+
}
|
|
1378
|
+
async function writeVibeTomlConfig(filePath, server, mode) {
|
|
1379
|
+
const existingText = await tryReadFile(filePath);
|
|
1380
|
+
const created = existingText === null;
|
|
1381
|
+
let config = {};
|
|
1382
|
+
if (existingText) {
|
|
1383
|
+
const existing = safeParseToml(existingText);
|
|
1384
|
+
if (existing && typeof existing === "object" && !Array.isArray(existing)) config = existing;
|
|
1385
|
+
}
|
|
1386
|
+
const entry = server.connection.transport === "http" ? {
|
|
1387
|
+
name: server.id,
|
|
1388
|
+
transport: "http",
|
|
1389
|
+
url: server.connection.url,
|
|
1390
|
+
headers: server.connection.headers
|
|
1391
|
+
} : {
|
|
1392
|
+
name: server.id,
|
|
1393
|
+
transport: "stdio",
|
|
1394
|
+
command: server.connection.command,
|
|
1395
|
+
args: server.connection.args,
|
|
1396
|
+
env: compactEnv(server.connection.env)
|
|
1397
|
+
};
|
|
1398
|
+
const existingServers = Array.isArray(config.mcp_servers) ? config.mcp_servers : [];
|
|
1399
|
+
const nextServers = mode === "overwrite" ? [entry] : [...existingServers.filter((s) => s?.name !== server.id), entry];
|
|
1400
|
+
const nextText = stringify({
|
|
1401
|
+
...config,
|
|
1402
|
+
mcp_servers: nextServers
|
|
1403
|
+
});
|
|
1404
|
+
await mkdir(dirname$1(filePath), { recursive: true });
|
|
1405
|
+
await writeFile(filePath, nextText);
|
|
1406
|
+
return {
|
|
1407
|
+
created,
|
|
1408
|
+
updated: created ? true : existingText !== nextText
|
|
1409
|
+
};
|
|
1410
|
+
}
|
|
1411
|
+
function toRulerLikeServerDef(server) {
|
|
1412
|
+
if (server.connection.transport === "stdio") return {
|
|
1413
|
+
command: server.connection.command,
|
|
1414
|
+
args: server.connection.args,
|
|
1415
|
+
env: server.connection.env
|
|
1416
|
+
};
|
|
1417
|
+
return {
|
|
1418
|
+
type: "remote",
|
|
1419
|
+
url: server.connection.url,
|
|
1420
|
+
headers: server.connection.headers
|
|
1421
|
+
};
|
|
1422
|
+
}
|
|
1423
|
+
function buildCodexTomlDocument(server) {
|
|
1424
|
+
return { mcp_servers: { [server.id]: toRulerLikeServerDef(server) } };
|
|
1425
|
+
}
|
|
1426
|
+
async function writeOpenHandsTomlConfig(filePath, server, mode) {
|
|
1427
|
+
const existingText = await tryReadFile(filePath);
|
|
1428
|
+
const created = existingText === null;
|
|
1429
|
+
let config = {};
|
|
1430
|
+
if (existingText) {
|
|
1431
|
+
const existing = safeParseToml(existingText);
|
|
1432
|
+
if (existing && typeof existing === "object" && !Array.isArray(existing)) config = existing;
|
|
1433
|
+
}
|
|
1434
|
+
config.mcp ||= {};
|
|
1435
|
+
config.mcp.stdio_servers ||= [];
|
|
1436
|
+
config.mcp.shttp_servers ||= [];
|
|
1437
|
+
if (mode === "overwrite") {
|
|
1438
|
+
config.mcp.stdio_servers = [];
|
|
1439
|
+
config.mcp.shttp_servers = [];
|
|
1440
|
+
}
|
|
1441
|
+
if (server.connection.transport === "stdio") {
|
|
1442
|
+
const next = {
|
|
1443
|
+
name: server.id,
|
|
1444
|
+
command: server.connection.command,
|
|
1445
|
+
args: server.connection.args,
|
|
1446
|
+
env: compactEnv(server.connection.env)
|
|
1447
|
+
};
|
|
1448
|
+
const byName = new Map(config.mcp.stdio_servers.map((s) => [s.name, s]));
|
|
1449
|
+
byName.set(server.id, next);
|
|
1450
|
+
config.mcp.stdio_servers = [...byName.values()];
|
|
1451
|
+
} else {
|
|
1452
|
+
const apiKey = (server.connection.headers?.Authorization)?.replace(BEARER_PREFIX_RE, "");
|
|
1453
|
+
const entry = apiKey ? {
|
|
1454
|
+
url: server.connection.url,
|
|
1455
|
+
api_key: apiKey
|
|
1456
|
+
} : server.connection.url;
|
|
1457
|
+
const byUrl = /* @__PURE__ */ new Map();
|
|
1458
|
+
for (const e of config.mcp.shttp_servers) {
|
|
1459
|
+
const url = typeof e === "string" ? e : e.url;
|
|
1460
|
+
byUrl.set(url, e);
|
|
1461
|
+
}
|
|
1462
|
+
byUrl.set(server.connection.url, entry);
|
|
1463
|
+
config.mcp.shttp_servers = [...byUrl.values()];
|
|
1464
|
+
}
|
|
1465
|
+
const nextText = stringify(config);
|
|
1466
|
+
await mkdir(dirname$1(filePath), { recursive: true });
|
|
1467
|
+
await writeFile(filePath, nextText);
|
|
1468
|
+
return {
|
|
1469
|
+
created,
|
|
1470
|
+
updated: created ? true : existingText !== nextText
|
|
1471
|
+
};
|
|
1472
|
+
}
|
|
1473
|
+
function compactEnv(env) {
|
|
1474
|
+
if (!env) return;
|
|
1475
|
+
const out = {};
|
|
1476
|
+
for (const [k, v] of Object.entries(env)) if (typeof v === "string" && v.length > 0) out[k] = v;
|
|
1477
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
1478
|
+
}
|
|
1479
|
+
function buildZedJsonDocument(server) {
|
|
1480
|
+
const { type: _type, ...withoutType } = toRulerLikeServerDef(server);
|
|
1481
|
+
return { context_servers: { [server.id]: {
|
|
1482
|
+
...withoutType,
|
|
1483
|
+
source: "custom"
|
|
1484
|
+
} } };
|
|
1485
|
+
}
|
|
1486
|
+
function buildOpenCodeJsonDocument(server) {
|
|
1487
|
+
if (server.connection.transport === "http") return {
|
|
1488
|
+
$schema: "https://opencode.ai/config.json",
|
|
1489
|
+
mcp: { [server.id]: {
|
|
1490
|
+
type: "remote",
|
|
1491
|
+
url: server.connection.url,
|
|
1492
|
+
enabled: true,
|
|
1493
|
+
headers: server.connection.headers
|
|
1494
|
+
} }
|
|
1495
|
+
};
|
|
1496
|
+
const command = [server.connection.command, ...server.connection.args ?? []];
|
|
1497
|
+
return {
|
|
1498
|
+
$schema: "https://opencode.ai/config.json",
|
|
1499
|
+
mcp: { [server.id]: {
|
|
1500
|
+
type: "local",
|
|
1501
|
+
command,
|
|
1502
|
+
enabled: true,
|
|
1503
|
+
environment: server.connection.env
|
|
1504
|
+
} }
|
|
1505
|
+
};
|
|
1506
|
+
}
|
|
1507
|
+
async function writeJsonConfig(filePath, nextDoc, mode) {
|
|
1508
|
+
const existingText = await tryReadFile(filePath);
|
|
1509
|
+
const created = existingText === null;
|
|
1510
|
+
let next = nextDoc;
|
|
1511
|
+
if (mode === "merge" && existingText) {
|
|
1512
|
+
const existing = safeParseJson(existingText);
|
|
1513
|
+
if (existing && typeof existing === "object" && !Array.isArray(existing)) next = deepMerge(existing, nextDoc);
|
|
1514
|
+
}
|
|
1515
|
+
const nextText = `${JSON.stringify(next, null, 2)}\n`;
|
|
1516
|
+
await mkdir(dirname$1(filePath), { recursive: true });
|
|
1517
|
+
await writeFile(filePath, nextText);
|
|
1518
|
+
return {
|
|
1519
|
+
created,
|
|
1520
|
+
updated: created ? true : existingText !== nextText
|
|
1521
|
+
};
|
|
1522
|
+
}
|
|
1523
|
+
async function writeTomlConfig(filePath, nextDoc, mode) {
|
|
1524
|
+
const existingText = await tryReadFile(filePath);
|
|
1525
|
+
const created = existingText === null;
|
|
1526
|
+
let next = nextDoc;
|
|
1527
|
+
if (mode === "merge" && existingText) {
|
|
1528
|
+
const existing = safeParseToml(existingText);
|
|
1529
|
+
if (existing && typeof existing === "object" && !Array.isArray(existing)) next = deepMerge(existing, nextDoc);
|
|
1530
|
+
}
|
|
1531
|
+
const nextText = stringify(next);
|
|
1532
|
+
await mkdir(dirname$1(filePath), { recursive: true });
|
|
1533
|
+
await writeFile(filePath, nextText);
|
|
1534
|
+
return {
|
|
1535
|
+
created,
|
|
1536
|
+
updated: created ? true : existingText !== nextText
|
|
1537
|
+
};
|
|
1538
|
+
}
|
|
1539
|
+
async function tryReadFile(filePath) {
|
|
1540
|
+
try {
|
|
1541
|
+
return await readFile(filePath, "utf8");
|
|
1542
|
+
} catch {
|
|
1543
|
+
return null;
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
function safeParseJson(text) {
|
|
1547
|
+
try {
|
|
1548
|
+
return JSON.parse(text);
|
|
1549
|
+
} catch {
|
|
1550
|
+
return null;
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
function safeParseToml(text) {
|
|
1554
|
+
try {
|
|
1555
|
+
return parse(text);
|
|
1556
|
+
} catch {
|
|
1557
|
+
return null;
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
function deepMerge(base, patch) {
|
|
1561
|
+
const next = { ...base };
|
|
1562
|
+
for (const [key, value] of Object.entries(patch)) {
|
|
1563
|
+
const prev = next[key];
|
|
1564
|
+
next[key] = isPlainObject(prev) && isPlainObject(value) ? deepMerge(prev, value) : value;
|
|
1565
|
+
}
|
|
1566
|
+
return next;
|
|
1567
|
+
}
|
|
1568
|
+
function isPlainObject(value) {
|
|
1569
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
1570
|
+
}
|
|
1571
|
+
//#endregion
|
|
1572
|
+
export { detectIDEs as a, normalize$1 as c, writeIdeMcpConfig as i, relative as l, buildIdeConfigDocument as n, dirname$1 as o, removeIdeMcpConfig as r, join$1 as s, buildClaudeCodeCommand as t, resolve$1 as u };
|