@mcpc-tech/cli 0.1.43 → 0.1.45
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/bin/mcpc.cjs +2636 -293
- package/bin/mcpc.mjs +2630 -287
- package/package.json +1 -2
- package/types/src/config/loader.d.ts.map +1 -1
package/bin/mcpc.cjs
CHANGED
|
@@ -48,15 +48,15 @@ var require_windows = __commonJS({
|
|
|
48
48
|
}
|
|
49
49
|
return false;
|
|
50
50
|
}
|
|
51
|
-
function checkStat(
|
|
52
|
-
if (!
|
|
51
|
+
function checkStat(stat2, path, options) {
|
|
52
|
+
if (!stat2.isSymbolicLink() && !stat2.isFile()) {
|
|
53
53
|
return false;
|
|
54
54
|
}
|
|
55
55
|
return checkPathExt(path, options);
|
|
56
56
|
}
|
|
57
57
|
function isexe(path, options, cb) {
|
|
58
|
-
fs.stat(path, function(er,
|
|
59
|
-
cb(er, er ? false : checkStat(
|
|
58
|
+
fs.stat(path, function(er, stat2) {
|
|
59
|
+
cb(er, er ? false : checkStat(stat2, path, options));
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
function sync(path, options) {
|
|
@@ -72,20 +72,20 @@ var require_mode = __commonJS({
|
|
|
72
72
|
isexe.sync = sync;
|
|
73
73
|
var fs = require("fs");
|
|
74
74
|
function isexe(path, options, cb) {
|
|
75
|
-
fs.stat(path, function(er,
|
|
76
|
-
cb(er, er ? false : checkStat(
|
|
75
|
+
fs.stat(path, function(er, stat2) {
|
|
76
|
+
cb(er, er ? false : checkStat(stat2, options));
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
function sync(path, options) {
|
|
80
80
|
return checkStat(fs.statSync(path), options);
|
|
81
81
|
}
|
|
82
|
-
function checkStat(
|
|
83
|
-
return
|
|
82
|
+
function checkStat(stat2, options) {
|
|
83
|
+
return stat2.isFile() && checkMode(stat2, options);
|
|
84
84
|
}
|
|
85
|
-
function checkMode(
|
|
86
|
-
var mod =
|
|
87
|
-
var uid =
|
|
88
|
-
var gid =
|
|
85
|
+
function checkMode(stat2, options) {
|
|
86
|
+
var mod = stat2.mode;
|
|
87
|
+
var uid = stat2.uid;
|
|
88
|
+
var gid = stat2.gid;
|
|
89
89
|
var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
|
|
90
90
|
var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
|
|
91
91
|
var u = parseInt("100", 8);
|
|
@@ -158,11 +158,11 @@ var require_which = __commonJS({
|
|
|
158
158
|
"__mcpc__cli_latest/node_modules/which/which.js"(exports2, module2) {
|
|
159
159
|
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
160
160
|
var path = require("path");
|
|
161
|
-
var
|
|
161
|
+
var COLON2 = isWindows ? ";" : ":";
|
|
162
162
|
var isexe = require_isexe();
|
|
163
163
|
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
164
164
|
var getPathInfo = (cmd, opt) => {
|
|
165
|
-
const colon = opt.colon ||
|
|
165
|
+
const colon = opt.colon || COLON2;
|
|
166
166
|
const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [
|
|
167
167
|
// windows always checks the cwd first
|
|
168
168
|
...isWindows ? [process.cwd()] : [],
|
|
@@ -352,11 +352,11 @@ var require_shebang_command = __commonJS({
|
|
|
352
352
|
return null;
|
|
353
353
|
}
|
|
354
354
|
const [path, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
355
|
-
const
|
|
356
|
-
if (
|
|
355
|
+
const binary2 = path.split("/").pop();
|
|
356
|
+
if (binary2 === "env") {
|
|
357
357
|
return argument;
|
|
358
358
|
}
|
|
359
|
-
return argument ? `${
|
|
359
|
+
return argument ? `${binary2} ${argument}` : binary2;
|
|
360
360
|
};
|
|
361
361
|
}
|
|
362
362
|
});
|
|
@@ -422,7 +422,7 @@ var require_parse = __commonJS({
|
|
|
422
422
|
}
|
|
423
423
|
return parsed;
|
|
424
424
|
}
|
|
425
|
-
function
|
|
425
|
+
function parse2(command, args, options) {
|
|
426
426
|
if (args && !Array.isArray(args)) {
|
|
427
427
|
options = args;
|
|
428
428
|
args = null;
|
|
@@ -441,7 +441,7 @@ var require_parse = __commonJS({
|
|
|
441
441
|
};
|
|
442
442
|
return options.shell ? parsed : parseNonShell(parsed);
|
|
443
443
|
}
|
|
444
|
-
module2.exports =
|
|
444
|
+
module2.exports = parse2;
|
|
445
445
|
}
|
|
446
446
|
});
|
|
447
447
|
|
|
@@ -500,16 +500,16 @@ var require_cross_spawn = __commonJS({
|
|
|
500
500
|
"__mcpc__cli_latest/node_modules/cross-spawn/index.js"(exports2, module2) {
|
|
501
501
|
"use strict";
|
|
502
502
|
var cp = require("child_process");
|
|
503
|
-
var
|
|
503
|
+
var parse2 = require_parse();
|
|
504
504
|
var enoent = require_enoent();
|
|
505
505
|
function spawn2(command, args, options) {
|
|
506
|
-
const parsed =
|
|
506
|
+
const parsed = parse2(command, args, options);
|
|
507
507
|
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
|
|
508
508
|
enoent.hookChildProcess(spawned, parsed);
|
|
509
509
|
return spawned;
|
|
510
510
|
}
|
|
511
511
|
function spawnSync(command, args, options) {
|
|
512
|
-
const parsed =
|
|
512
|
+
const parsed = parse2(command, args, options);
|
|
513
513
|
const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
|
|
514
514
|
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
515
515
|
return result;
|
|
@@ -517,7 +517,7 @@ var require_cross_spawn = __commonJS({
|
|
|
517
517
|
module2.exports = spawn2;
|
|
518
518
|
module2.exports.spawn = spawn2;
|
|
519
519
|
module2.exports.sync = spawnSync;
|
|
520
|
-
module2.exports._parse =
|
|
520
|
+
module2.exports._parse = parse2;
|
|
521
521
|
module2.exports._enoent = enoent;
|
|
522
522
|
}
|
|
523
523
|
});
|
|
@@ -2377,11 +2377,269 @@ if (typeof global.crypto === "undefined") {
|
|
|
2377
2377
|
}
|
|
2378
2378
|
var outgoingEnded = Symbol("outgoingEnded");
|
|
2379
2379
|
|
|
2380
|
+
// __mcpc__cli_latest/node_modules/@jsr/std__cli/parse_args.js
|
|
2381
|
+
var FLAG_REGEXP = /^(?:-(?:(?<doubleDash>-)(?<negated>no-)?)?)(?<key>.+?)(?:=(?<value>.+?))?$/s;
|
|
2382
|
+
var LETTER_REGEXP = /[A-Za-z]/;
|
|
2383
|
+
var NUMBER_REGEXP = /-?\d+(\.\d*)?(e-?\d+)?$/;
|
|
2384
|
+
var HYPHEN_REGEXP = /^(-|--)[^-]/;
|
|
2385
|
+
var VALUE_REGEXP = /=(?<value>.+)/;
|
|
2386
|
+
var FLAG_NAME_REGEXP = /^--[^=]+$/;
|
|
2387
|
+
var SPECIAL_CHAR_REGEXP = /\W/;
|
|
2388
|
+
var NON_WHITESPACE_REGEXP = /\S/;
|
|
2389
|
+
function isNumber(string3) {
|
|
2390
|
+
return NON_WHITESPACE_REGEXP.test(string3) && Number.isFinite(Number(string3));
|
|
2391
|
+
}
|
|
2392
|
+
function setNested(object5, keys, value, collect = false) {
|
|
2393
|
+
keys = [
|
|
2394
|
+
...keys
|
|
2395
|
+
];
|
|
2396
|
+
const key = keys.pop();
|
|
2397
|
+
keys.forEach((key2) => object5 = object5[key2] ??= {});
|
|
2398
|
+
if (collect) {
|
|
2399
|
+
const v = object5[key];
|
|
2400
|
+
if (Array.isArray(v)) {
|
|
2401
|
+
v.push(value);
|
|
2402
|
+
return;
|
|
2403
|
+
}
|
|
2404
|
+
value = v ? [
|
|
2405
|
+
v,
|
|
2406
|
+
value
|
|
2407
|
+
] : [
|
|
2408
|
+
value
|
|
2409
|
+
];
|
|
2410
|
+
}
|
|
2411
|
+
object5[key] = value;
|
|
2412
|
+
}
|
|
2413
|
+
function hasNested(object5, keys) {
|
|
2414
|
+
for (const key of keys) {
|
|
2415
|
+
const value = object5[key];
|
|
2416
|
+
if (!Object.hasOwn(object5, key)) return false;
|
|
2417
|
+
object5 = value;
|
|
2418
|
+
}
|
|
2419
|
+
return true;
|
|
2420
|
+
}
|
|
2421
|
+
function aliasIsBoolean(aliasMap, booleanSet, key) {
|
|
2422
|
+
const set2 = aliasMap.get(key);
|
|
2423
|
+
if (set2 === void 0) return false;
|
|
2424
|
+
for (const alias of set2) if (booleanSet.has(alias)) return true;
|
|
2425
|
+
return false;
|
|
2426
|
+
}
|
|
2427
|
+
function isBooleanString(value) {
|
|
2428
|
+
return value === "true" || value === "false";
|
|
2429
|
+
}
|
|
2430
|
+
function parseBooleanString(value) {
|
|
2431
|
+
return value !== "false";
|
|
2432
|
+
}
|
|
2433
|
+
function parseArgs(args, options) {
|
|
2434
|
+
const { "--": doubleDash = false, alias = {}, boolean: boolean3 = false, default: defaults = {}, stopEarly = false, string: string3 = [], collect = [], negatable = [], unknown: unknownFn = (i) => i } = options ?? {};
|
|
2435
|
+
const aliasMap = /* @__PURE__ */ new Map();
|
|
2436
|
+
const booleanSet = /* @__PURE__ */ new Set();
|
|
2437
|
+
const stringSet = /* @__PURE__ */ new Set();
|
|
2438
|
+
const collectSet = /* @__PURE__ */ new Set();
|
|
2439
|
+
const negatableSet = /* @__PURE__ */ new Set();
|
|
2440
|
+
let allBools = false;
|
|
2441
|
+
if (alias) {
|
|
2442
|
+
for (const [key, value] of Object.entries(alias)) {
|
|
2443
|
+
if (value === void 0) {
|
|
2444
|
+
throw new TypeError("Alias value must be defined");
|
|
2445
|
+
}
|
|
2446
|
+
const aliases = Array.isArray(value) ? value : [
|
|
2447
|
+
value
|
|
2448
|
+
];
|
|
2449
|
+
aliasMap.set(key, new Set(aliases));
|
|
2450
|
+
aliases.forEach((alias2) => aliasMap.set(alias2, /* @__PURE__ */ new Set([
|
|
2451
|
+
key,
|
|
2452
|
+
...aliases.filter((it) => it !== alias2)
|
|
2453
|
+
])));
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
if (boolean3) {
|
|
2457
|
+
if (typeof boolean3 === "boolean") {
|
|
2458
|
+
allBools = boolean3;
|
|
2459
|
+
} else {
|
|
2460
|
+
const booleanArgs = Array.isArray(boolean3) ? boolean3 : [
|
|
2461
|
+
boolean3
|
|
2462
|
+
];
|
|
2463
|
+
for (const key of booleanArgs.filter(Boolean)) {
|
|
2464
|
+
booleanSet.add(key);
|
|
2465
|
+
aliasMap.get(key)?.forEach((al) => {
|
|
2466
|
+
booleanSet.add(al);
|
|
2467
|
+
});
|
|
2468
|
+
}
|
|
2469
|
+
}
|
|
2470
|
+
}
|
|
2471
|
+
if (string3) {
|
|
2472
|
+
const stringArgs = Array.isArray(string3) ? string3 : [
|
|
2473
|
+
string3
|
|
2474
|
+
];
|
|
2475
|
+
for (const key of stringArgs.filter(Boolean)) {
|
|
2476
|
+
stringSet.add(key);
|
|
2477
|
+
aliasMap.get(key)?.forEach((al) => stringSet.add(al));
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2480
|
+
if (collect) {
|
|
2481
|
+
const collectArgs = Array.isArray(collect) ? collect : [
|
|
2482
|
+
collect
|
|
2483
|
+
];
|
|
2484
|
+
for (const key of collectArgs.filter(Boolean)) {
|
|
2485
|
+
collectSet.add(key);
|
|
2486
|
+
aliasMap.get(key)?.forEach((al) => collectSet.add(al));
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2489
|
+
if (negatable) {
|
|
2490
|
+
const negatableArgs = Array.isArray(negatable) ? negatable : [
|
|
2491
|
+
negatable
|
|
2492
|
+
];
|
|
2493
|
+
for (const key of negatableArgs.filter(Boolean)) {
|
|
2494
|
+
negatableSet.add(key);
|
|
2495
|
+
aliasMap.get(key)?.forEach((alias2) => negatableSet.add(alias2));
|
|
2496
|
+
}
|
|
2497
|
+
}
|
|
2498
|
+
const argv = {
|
|
2499
|
+
_: []
|
|
2500
|
+
};
|
|
2501
|
+
function setArgument(key, value, arg, collect2) {
|
|
2502
|
+
if (!booleanSet.has(key) && !stringSet.has(key) && !aliasMap.has(key) && !collectSet.has(key) && !(allBools && FLAG_NAME_REGEXP.test(arg)) && unknownFn?.(arg, key, value) === false) {
|
|
2503
|
+
return;
|
|
2504
|
+
}
|
|
2505
|
+
if (typeof value === "string" && !stringSet.has(key)) {
|
|
2506
|
+
value = isNumber(value) ? Number(value) : value;
|
|
2507
|
+
}
|
|
2508
|
+
const collectable = collect2 && collectSet.has(key);
|
|
2509
|
+
setNested(argv, key.split("."), value, collectable);
|
|
2510
|
+
aliasMap.get(key)?.forEach((key2) => {
|
|
2511
|
+
setNested(argv, key2.split("."), value, collectable);
|
|
2512
|
+
});
|
|
2513
|
+
}
|
|
2514
|
+
let notFlags = [];
|
|
2515
|
+
const index = args.indexOf("--");
|
|
2516
|
+
if (index !== -1) {
|
|
2517
|
+
notFlags = args.slice(index + 1);
|
|
2518
|
+
args = args.slice(0, index);
|
|
2519
|
+
}
|
|
2520
|
+
argsLoop: for (let i = 0; i < args.length; i++) {
|
|
2521
|
+
const arg = args[i];
|
|
2522
|
+
const groups = arg.match(FLAG_REGEXP)?.groups;
|
|
2523
|
+
if (groups) {
|
|
2524
|
+
const { doubleDash: doubleDash2, negated } = groups;
|
|
2525
|
+
let key = groups.key;
|
|
2526
|
+
let value = groups.value;
|
|
2527
|
+
if (doubleDash2) {
|
|
2528
|
+
if (value) {
|
|
2529
|
+
if (booleanSet.has(key)) value = parseBooleanString(value);
|
|
2530
|
+
setArgument(key, value, arg, true);
|
|
2531
|
+
continue;
|
|
2532
|
+
}
|
|
2533
|
+
if (negated) {
|
|
2534
|
+
if (negatableSet.has(key)) {
|
|
2535
|
+
setArgument(key, false, arg, false);
|
|
2536
|
+
continue;
|
|
2537
|
+
}
|
|
2538
|
+
key = `no-${key}`;
|
|
2539
|
+
}
|
|
2540
|
+
const next = args[i + 1];
|
|
2541
|
+
if (next) {
|
|
2542
|
+
if (!booleanSet.has(key) && !allBools && !next.startsWith("-") && (!aliasMap.has(key) || !aliasIsBoolean(aliasMap, booleanSet, key))) {
|
|
2543
|
+
value = next;
|
|
2544
|
+
i++;
|
|
2545
|
+
setArgument(key, value, arg, true);
|
|
2546
|
+
continue;
|
|
2547
|
+
}
|
|
2548
|
+
if (isBooleanString(next)) {
|
|
2549
|
+
value = parseBooleanString(next);
|
|
2550
|
+
i++;
|
|
2551
|
+
setArgument(key, value, arg, true);
|
|
2552
|
+
continue;
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
value = stringSet.has(key) ? "" : true;
|
|
2556
|
+
setArgument(key, value, arg, true);
|
|
2557
|
+
continue;
|
|
2558
|
+
}
|
|
2559
|
+
const letters = arg.slice(1, -1).split("");
|
|
2560
|
+
for (const [j, letter] of letters.entries()) {
|
|
2561
|
+
const next = arg.slice(j + 2);
|
|
2562
|
+
if (next === "-") {
|
|
2563
|
+
setArgument(letter, next, arg, true);
|
|
2564
|
+
continue;
|
|
2565
|
+
}
|
|
2566
|
+
if (LETTER_REGEXP.test(letter)) {
|
|
2567
|
+
const groups2 = VALUE_REGEXP.exec(next)?.groups;
|
|
2568
|
+
if (groups2) {
|
|
2569
|
+
setArgument(letter, groups2.value, arg, true);
|
|
2570
|
+
continue argsLoop;
|
|
2571
|
+
}
|
|
2572
|
+
if (NUMBER_REGEXP.test(next)) {
|
|
2573
|
+
setArgument(letter, next, arg, true);
|
|
2574
|
+
continue argsLoop;
|
|
2575
|
+
}
|
|
2576
|
+
}
|
|
2577
|
+
if (letters[j + 1]?.match(SPECIAL_CHAR_REGEXP)) {
|
|
2578
|
+
setArgument(letter, arg.slice(j + 2), arg, true);
|
|
2579
|
+
continue argsLoop;
|
|
2580
|
+
}
|
|
2581
|
+
setArgument(letter, stringSet.has(letter) ? "" : true, arg, true);
|
|
2582
|
+
}
|
|
2583
|
+
key = arg.slice(-1);
|
|
2584
|
+
if (key === "-") continue;
|
|
2585
|
+
const nextArg = args[i + 1];
|
|
2586
|
+
if (nextArg) {
|
|
2587
|
+
if (!HYPHEN_REGEXP.test(nextArg) && !booleanSet.has(key) && (!aliasMap.has(key) || !aliasIsBoolean(aliasMap, booleanSet, key))) {
|
|
2588
|
+
setArgument(key, nextArg, arg, true);
|
|
2589
|
+
i++;
|
|
2590
|
+
continue;
|
|
2591
|
+
}
|
|
2592
|
+
if (isBooleanString(nextArg)) {
|
|
2593
|
+
const value2 = parseBooleanString(nextArg);
|
|
2594
|
+
setArgument(key, value2, arg, true);
|
|
2595
|
+
i++;
|
|
2596
|
+
continue;
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
setArgument(key, stringSet.has(key) ? "" : true, arg, true);
|
|
2600
|
+
continue;
|
|
2601
|
+
}
|
|
2602
|
+
if (unknownFn?.(arg) !== false) {
|
|
2603
|
+
argv._.push(stringSet.has("_") || !isNumber(arg) ? arg : Number(arg));
|
|
2604
|
+
}
|
|
2605
|
+
if (stopEarly) {
|
|
2606
|
+
argv._.push(...args.slice(i + 1));
|
|
2607
|
+
break;
|
|
2608
|
+
}
|
|
2609
|
+
}
|
|
2610
|
+
for (const [key, value] of Object.entries(defaults)) {
|
|
2611
|
+
const keys = key.split(".");
|
|
2612
|
+
if (!hasNested(argv, keys)) {
|
|
2613
|
+
setNested(argv, keys, value);
|
|
2614
|
+
aliasMap.get(key)?.forEach((key2) => setNested(argv, key2.split("."), value));
|
|
2615
|
+
}
|
|
2616
|
+
}
|
|
2617
|
+
for (const key of booleanSet.keys()) {
|
|
2618
|
+
const keys = key.split(".");
|
|
2619
|
+
if (!hasNested(argv, keys)) {
|
|
2620
|
+
const value = collectSet.has(key) ? [] : false;
|
|
2621
|
+
setNested(argv, keys, value);
|
|
2622
|
+
}
|
|
2623
|
+
}
|
|
2624
|
+
for (const key of stringSet.keys()) {
|
|
2625
|
+
const keys = key.split(".");
|
|
2626
|
+
if (!hasNested(argv, keys) && collectSet.has(key)) {
|
|
2627
|
+
setNested(argv, keys, []);
|
|
2628
|
+
}
|
|
2629
|
+
}
|
|
2630
|
+
if (doubleDash) {
|
|
2631
|
+
argv["--"] = notFlags;
|
|
2632
|
+
} else {
|
|
2633
|
+
argv._.push(...notFlags);
|
|
2634
|
+
}
|
|
2635
|
+
return argv;
|
|
2636
|
+
}
|
|
2637
|
+
|
|
2380
2638
|
// __mcpc__cli_latest/node_modules/@mcpc/cli/src/config/loader.js
|
|
2381
|
-
var
|
|
2639
|
+
var import_promises4 = require("node:fs/promises");
|
|
2382
2640
|
var import_node_os3 = require("node:os");
|
|
2383
2641
|
var import_node_path6 = require("node:path");
|
|
2384
|
-
var
|
|
2642
|
+
var import_node_process4 = __toESM(require("node:process"), 1);
|
|
2385
2643
|
|
|
2386
2644
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugins/large-result.js
|
|
2387
2645
|
var import_promises = require("node:fs/promises");
|
|
@@ -2857,100 +3115,2141 @@ Available skills: ${available.join(", ")}` : "\n\nNo skills available.";
|
|
|
2857
3115
|
isError: true
|
|
2858
3116
|
};
|
|
2859
3117
|
}
|
|
2860
|
-
if (args.ref) {
|
|
2861
|
-
const refPath = (0, import_node_path4.resolve)(meta.basePath, args.ref);
|
|
2862
|
-
const relPath = (0, import_node_path4.relative)(meta.basePath, refPath);
|
|
2863
|
-
if (relPath.startsWith("..")) {
|
|
2864
|
-
return {
|
|
2865
|
-
content: [
|
|
2866
|
-
{
|
|
2867
|
-
type: "text",
|
|
2868
|
-
text: `Invalid path: ${args.ref}`
|
|
2869
|
-
}
|
|
2870
|
-
],
|
|
2871
|
-
isError: true
|
|
2872
|
-
};
|
|
2873
|
-
}
|
|
2874
|
-
const dir = relPath.split(/[/\\]/)[0];
|
|
2875
|
-
if (dir === "scripts" || dir === "assets") {
|
|
2876
|
-
return {
|
|
2877
|
-
content: [
|
|
2878
|
-
{
|
|
2879
|
-
type: "text",
|
|
2880
|
-
text: `Path: ${refPath}`
|
|
2881
|
-
}
|
|
2882
|
-
]
|
|
2883
|
-
};
|
|
3118
|
+
if (args.ref) {
|
|
3119
|
+
const refPath = (0, import_node_path4.resolve)(meta.basePath, args.ref);
|
|
3120
|
+
const relPath = (0, import_node_path4.relative)(meta.basePath, refPath);
|
|
3121
|
+
if (relPath.startsWith("..")) {
|
|
3122
|
+
return {
|
|
3123
|
+
content: [
|
|
3124
|
+
{
|
|
3125
|
+
type: "text",
|
|
3126
|
+
text: `Invalid path: ${args.ref}`
|
|
3127
|
+
}
|
|
3128
|
+
],
|
|
3129
|
+
isError: true
|
|
3130
|
+
};
|
|
3131
|
+
}
|
|
3132
|
+
const dir = relPath.split(/[/\\]/)[0];
|
|
3133
|
+
if (dir === "scripts" || dir === "assets") {
|
|
3134
|
+
return {
|
|
3135
|
+
content: [
|
|
3136
|
+
{
|
|
3137
|
+
type: "text",
|
|
3138
|
+
text: `Path: ${refPath}`
|
|
3139
|
+
}
|
|
3140
|
+
]
|
|
3141
|
+
};
|
|
3142
|
+
}
|
|
3143
|
+
try {
|
|
3144
|
+
const content = await (0, import_promises2.readFile)(refPath, "utf-8");
|
|
3145
|
+
return {
|
|
3146
|
+
content: [
|
|
3147
|
+
{
|
|
3148
|
+
type: "text",
|
|
3149
|
+
text: content
|
|
3150
|
+
}
|
|
3151
|
+
]
|
|
3152
|
+
};
|
|
3153
|
+
} catch {
|
|
3154
|
+
return {
|
|
3155
|
+
content: [
|
|
3156
|
+
{
|
|
3157
|
+
type: "text",
|
|
3158
|
+
text: `File not found: ${args.ref}`
|
|
3159
|
+
}
|
|
3160
|
+
],
|
|
3161
|
+
isError: true
|
|
3162
|
+
};
|
|
3163
|
+
}
|
|
3164
|
+
}
|
|
3165
|
+
try {
|
|
3166
|
+
const content = await (0, import_promises2.readFile)((0, import_node_path4.join)(meta.basePath, "SKILL.md"), "utf-8");
|
|
3167
|
+
const body = extractBody(content);
|
|
3168
|
+
return {
|
|
3169
|
+
content: [
|
|
3170
|
+
{
|
|
3171
|
+
type: "text",
|
|
3172
|
+
text: body
|
|
3173
|
+
}
|
|
3174
|
+
]
|
|
3175
|
+
};
|
|
3176
|
+
} catch {
|
|
3177
|
+
return {
|
|
3178
|
+
content: [
|
|
3179
|
+
{
|
|
3180
|
+
type: "text",
|
|
3181
|
+
text: `Failed to load skill: ${args.skill}`
|
|
3182
|
+
}
|
|
3183
|
+
],
|
|
3184
|
+
isError: true
|
|
3185
|
+
};
|
|
3186
|
+
}
|
|
3187
|
+
}, {
|
|
3188
|
+
internal: true
|
|
3189
|
+
});
|
|
3190
|
+
}
|
|
3191
|
+
},
|
|
3192
|
+
dispose: () => {
|
|
3193
|
+
skillsMap.clear();
|
|
3194
|
+
serverRef = null;
|
|
3195
|
+
}
|
|
3196
|
+
};
|
|
3197
|
+
}
|
|
3198
|
+
|
|
3199
|
+
// __mcpc__cli_latest/node_modules/@mcpc/cli/src/defaults.js
|
|
3200
|
+
var import_plugin_code_execution = require("@mcpc-tech/plugin-code-execution");
|
|
3201
|
+
|
|
3202
|
+
// __mcpc__cli_latest/node_modules/@jsr/mcpc__plugin-markdown-loader/src/markdown-loader.js
|
|
3203
|
+
var import_promises3 = require("node:fs/promises");
|
|
3204
|
+
|
|
3205
|
+
// __mcpc__cli_latest/node_modules/@jsr/std__yaml/_chars.js
|
|
3206
|
+
var TAB = 9;
|
|
3207
|
+
var LINE_FEED = 10;
|
|
3208
|
+
var CARRIAGE_RETURN = 13;
|
|
3209
|
+
var SPACE = 32;
|
|
3210
|
+
var EXCLAMATION = 33;
|
|
3211
|
+
var DOUBLE_QUOTE = 34;
|
|
3212
|
+
var SHARP = 35;
|
|
3213
|
+
var PERCENT = 37;
|
|
3214
|
+
var AMPERSAND = 38;
|
|
3215
|
+
var SINGLE_QUOTE = 39;
|
|
3216
|
+
var ASTERISK = 42;
|
|
3217
|
+
var PLUS = 43;
|
|
3218
|
+
var COMMA = 44;
|
|
3219
|
+
var MINUS = 45;
|
|
3220
|
+
var DOT = 46;
|
|
3221
|
+
var COLON = 58;
|
|
3222
|
+
var SMALLER_THAN = 60;
|
|
3223
|
+
var GREATER_THAN = 62;
|
|
3224
|
+
var QUESTION = 63;
|
|
3225
|
+
var COMMERCIAL_AT = 64;
|
|
3226
|
+
var LEFT_SQUARE_BRACKET = 91;
|
|
3227
|
+
var BACKSLASH = 92;
|
|
3228
|
+
var RIGHT_SQUARE_BRACKET = 93;
|
|
3229
|
+
var GRAVE_ACCENT = 96;
|
|
3230
|
+
var LEFT_CURLY_BRACKET = 123;
|
|
3231
|
+
var VERTICAL_LINE = 124;
|
|
3232
|
+
var RIGHT_CURLY_BRACKET = 125;
|
|
3233
|
+
function isEOL(c) {
|
|
3234
|
+
return c === LINE_FEED || c === CARRIAGE_RETURN;
|
|
3235
|
+
}
|
|
3236
|
+
function isWhiteSpace(c) {
|
|
3237
|
+
return c === TAB || c === SPACE;
|
|
3238
|
+
}
|
|
3239
|
+
function isWhiteSpaceOrEOL(c) {
|
|
3240
|
+
return isWhiteSpace(c) || isEOL(c);
|
|
3241
|
+
}
|
|
3242
|
+
function isFlowIndicator(c) {
|
|
3243
|
+
return c === COMMA || c === LEFT_SQUARE_BRACKET || c === RIGHT_SQUARE_BRACKET || c === LEFT_CURLY_BRACKET || c === RIGHT_CURLY_BRACKET;
|
|
3244
|
+
}
|
|
3245
|
+
|
|
3246
|
+
// __mcpc__cli_latest/node_modules/@jsr/std__yaml/_type/binary.js
|
|
3247
|
+
var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
|
|
3248
|
+
function resolveYamlBinary(data) {
|
|
3249
|
+
if (data === null) return false;
|
|
3250
|
+
let code;
|
|
3251
|
+
let bitlen = 0;
|
|
3252
|
+
const max = data.length;
|
|
3253
|
+
const map2 = BASE64_MAP;
|
|
3254
|
+
for (let idx = 0; idx < max; idx++) {
|
|
3255
|
+
code = map2.indexOf(data.charAt(idx));
|
|
3256
|
+
if (code > 64) continue;
|
|
3257
|
+
if (code < 0) return false;
|
|
3258
|
+
bitlen += 6;
|
|
3259
|
+
}
|
|
3260
|
+
return bitlen % 8 === 0;
|
|
3261
|
+
}
|
|
3262
|
+
function constructYamlBinary(data) {
|
|
3263
|
+
const input = data.replace(/[\r\n=]/g, "");
|
|
3264
|
+
const max = input.length;
|
|
3265
|
+
const map2 = BASE64_MAP;
|
|
3266
|
+
const result = [];
|
|
3267
|
+
let bits = 0;
|
|
3268
|
+
for (let idx = 0; idx < max; idx++) {
|
|
3269
|
+
if (idx % 4 === 0 && idx) {
|
|
3270
|
+
result.push(bits >> 16 & 255);
|
|
3271
|
+
result.push(bits >> 8 & 255);
|
|
3272
|
+
result.push(bits & 255);
|
|
3273
|
+
}
|
|
3274
|
+
bits = bits << 6 | map2.indexOf(input.charAt(idx));
|
|
3275
|
+
}
|
|
3276
|
+
const tailbits = max % 4 * 6;
|
|
3277
|
+
if (tailbits === 0) {
|
|
3278
|
+
result.push(bits >> 16 & 255);
|
|
3279
|
+
result.push(bits >> 8 & 255);
|
|
3280
|
+
result.push(bits & 255);
|
|
3281
|
+
} else if (tailbits === 18) {
|
|
3282
|
+
result.push(bits >> 10 & 255);
|
|
3283
|
+
result.push(bits >> 2 & 255);
|
|
3284
|
+
} else if (tailbits === 12) {
|
|
3285
|
+
result.push(bits >> 4 & 255);
|
|
3286
|
+
}
|
|
3287
|
+
return new Uint8Array(result);
|
|
3288
|
+
}
|
|
3289
|
+
function representYamlBinary(object5) {
|
|
3290
|
+
const max = object5.length;
|
|
3291
|
+
const map2 = BASE64_MAP;
|
|
3292
|
+
let result = "";
|
|
3293
|
+
let bits = 0;
|
|
3294
|
+
for (let idx = 0; idx < max; idx++) {
|
|
3295
|
+
if (idx % 3 === 0 && idx) {
|
|
3296
|
+
result += map2[bits >> 18 & 63];
|
|
3297
|
+
result += map2[bits >> 12 & 63];
|
|
3298
|
+
result += map2[bits >> 6 & 63];
|
|
3299
|
+
result += map2[bits & 63];
|
|
3300
|
+
}
|
|
3301
|
+
bits = (bits << 8) + object5[idx];
|
|
3302
|
+
}
|
|
3303
|
+
const tail = max % 3;
|
|
3304
|
+
if (tail === 0) {
|
|
3305
|
+
result += map2[bits >> 18 & 63];
|
|
3306
|
+
result += map2[bits >> 12 & 63];
|
|
3307
|
+
result += map2[bits >> 6 & 63];
|
|
3308
|
+
result += map2[bits & 63];
|
|
3309
|
+
} else if (tail === 2) {
|
|
3310
|
+
result += map2[bits >> 10 & 63];
|
|
3311
|
+
result += map2[bits >> 4 & 63];
|
|
3312
|
+
result += map2[bits << 2 & 63];
|
|
3313
|
+
result += map2[64];
|
|
3314
|
+
} else if (tail === 1) {
|
|
3315
|
+
result += map2[bits >> 2 & 63];
|
|
3316
|
+
result += map2[bits << 4 & 63];
|
|
3317
|
+
result += map2[64];
|
|
3318
|
+
result += map2[64];
|
|
3319
|
+
}
|
|
3320
|
+
return result;
|
|
3321
|
+
}
|
|
3322
|
+
function isBinary(obj) {
|
|
3323
|
+
return obj instanceof Uint8Array;
|
|
3324
|
+
}
|
|
3325
|
+
var binary = {
|
|
3326
|
+
tag: "tag:yaml.org,2002:binary",
|
|
3327
|
+
construct: constructYamlBinary,
|
|
3328
|
+
kind: "scalar",
|
|
3329
|
+
predicate: isBinary,
|
|
3330
|
+
represent: representYamlBinary,
|
|
3331
|
+
resolve: resolveYamlBinary
|
|
3332
|
+
};
|
|
3333
|
+
|
|
3334
|
+
// __mcpc__cli_latest/node_modules/@jsr/std__yaml/_type/bool.js
|
|
3335
|
+
var YAML_TRUE_BOOLEANS = [
|
|
3336
|
+
"true",
|
|
3337
|
+
"True",
|
|
3338
|
+
"TRUE"
|
|
3339
|
+
];
|
|
3340
|
+
var YAML_FALSE_BOOLEANS = [
|
|
3341
|
+
"false",
|
|
3342
|
+
"False",
|
|
3343
|
+
"FALSE"
|
|
3344
|
+
];
|
|
3345
|
+
var YAML_BOOLEANS = [
|
|
3346
|
+
...YAML_TRUE_BOOLEANS,
|
|
3347
|
+
...YAML_FALSE_BOOLEANS
|
|
3348
|
+
];
|
|
3349
|
+
var bool = {
|
|
3350
|
+
tag: "tag:yaml.org,2002:bool",
|
|
3351
|
+
kind: "scalar",
|
|
3352
|
+
defaultStyle: "lowercase",
|
|
3353
|
+
predicate: (value) => typeof value === "boolean" || value instanceof Boolean,
|
|
3354
|
+
construct: (data) => YAML_TRUE_BOOLEANS.includes(data),
|
|
3355
|
+
resolve: (data) => YAML_BOOLEANS.includes(data),
|
|
3356
|
+
represent: {
|
|
3357
|
+
// deno-lint-ignore ban-types
|
|
3358
|
+
lowercase: (object5) => {
|
|
3359
|
+
const value = object5 instanceof Boolean ? object5.valueOf() : object5;
|
|
3360
|
+
return value ? "true" : "false";
|
|
3361
|
+
},
|
|
3362
|
+
// deno-lint-ignore ban-types
|
|
3363
|
+
uppercase: (object5) => {
|
|
3364
|
+
const value = object5 instanceof Boolean ? object5.valueOf() : object5;
|
|
3365
|
+
return value ? "TRUE" : "FALSE";
|
|
3366
|
+
},
|
|
3367
|
+
// deno-lint-ignore ban-types
|
|
3368
|
+
camelcase: (object5) => {
|
|
3369
|
+
const value = object5 instanceof Boolean ? object5.valueOf() : object5;
|
|
3370
|
+
return value ? "True" : "False";
|
|
3371
|
+
}
|
|
3372
|
+
}
|
|
3373
|
+
};
|
|
3374
|
+
|
|
3375
|
+
// __mcpc__cli_latest/node_modules/@jsr/std__yaml/_utils.js
|
|
3376
|
+
function isObject(value) {
|
|
3377
|
+
return value !== null && typeof value === "object";
|
|
3378
|
+
}
|
|
3379
|
+
function isNegativeZero(i) {
|
|
3380
|
+
return i === 0 && Number.NEGATIVE_INFINITY === 1 / i;
|
|
3381
|
+
}
|
|
3382
|
+
function isPlainObject(object5) {
|
|
3383
|
+
return Object.prototype.toString.call(object5) === "[object Object]";
|
|
3384
|
+
}
|
|
3385
|
+
|
|
3386
|
+
// __mcpc__cli_latest/node_modules/@jsr/std__yaml/_type/float.js
|
|
3387
|
+
var YAML_FLOAT_PATTERN = new RegExp(
|
|
3388
|
+
// 2.5e4, 2.5 and integers
|
|
3389
|
+
"^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"
|
|
3390
|
+
);
|
|
3391
|
+
function resolveYamlFloat(data) {
|
|
3392
|
+
if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_`
|
|
3393
|
+
// Probably should update regexp & check speed
|
|
3394
|
+
data[data.length - 1] === "_") {
|
|
3395
|
+
return false;
|
|
3396
|
+
}
|
|
3397
|
+
return true;
|
|
3398
|
+
}
|
|
3399
|
+
function constructYamlFloat(data) {
|
|
3400
|
+
let value = data.replace(/_/g, "").toLowerCase();
|
|
3401
|
+
const sign = value[0] === "-" ? -1 : 1;
|
|
3402
|
+
if (value[0] && "+-".includes(value[0])) {
|
|
3403
|
+
value = value.slice(1);
|
|
3404
|
+
}
|
|
3405
|
+
if (value === ".inf") {
|
|
3406
|
+
return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
3407
|
+
}
|
|
3408
|
+
if (value === ".nan") {
|
|
3409
|
+
return NaN;
|
|
3410
|
+
}
|
|
3411
|
+
return sign * parseFloat(value);
|
|
3412
|
+
}
|
|
3413
|
+
var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
|
|
3414
|
+
function representYamlFloat(object5, style) {
|
|
3415
|
+
const value = object5 instanceof Number ? object5.valueOf() : object5;
|
|
3416
|
+
if (isNaN(value)) {
|
|
3417
|
+
switch (style) {
|
|
3418
|
+
case "lowercase":
|
|
3419
|
+
return ".nan";
|
|
3420
|
+
case "uppercase":
|
|
3421
|
+
return ".NAN";
|
|
3422
|
+
case "camelcase":
|
|
3423
|
+
return ".NaN";
|
|
3424
|
+
}
|
|
3425
|
+
} else if (Number.POSITIVE_INFINITY === value) {
|
|
3426
|
+
switch (style) {
|
|
3427
|
+
case "lowercase":
|
|
3428
|
+
return ".inf";
|
|
3429
|
+
case "uppercase":
|
|
3430
|
+
return ".INF";
|
|
3431
|
+
case "camelcase":
|
|
3432
|
+
return ".Inf";
|
|
3433
|
+
}
|
|
3434
|
+
} else if (Number.NEGATIVE_INFINITY === value) {
|
|
3435
|
+
switch (style) {
|
|
3436
|
+
case "lowercase":
|
|
3437
|
+
return "-.inf";
|
|
3438
|
+
case "uppercase":
|
|
3439
|
+
return "-.INF";
|
|
3440
|
+
case "camelcase":
|
|
3441
|
+
return "-.Inf";
|
|
3442
|
+
}
|
|
3443
|
+
} else if (isNegativeZero(value)) {
|
|
3444
|
+
return "-0.0";
|
|
3445
|
+
}
|
|
3446
|
+
const res = value.toString(10);
|
|
3447
|
+
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
|
|
3448
|
+
}
|
|
3449
|
+
function isFloat(object5) {
|
|
3450
|
+
if (object5 instanceof Number) object5 = object5.valueOf();
|
|
3451
|
+
return typeof object5 === "number" && (object5 % 1 !== 0 || isNegativeZero(object5));
|
|
3452
|
+
}
|
|
3453
|
+
var float = {
|
|
3454
|
+
tag: "tag:yaml.org,2002:float",
|
|
3455
|
+
construct: constructYamlFloat,
|
|
3456
|
+
defaultStyle: "lowercase",
|
|
3457
|
+
kind: "scalar",
|
|
3458
|
+
predicate: isFloat,
|
|
3459
|
+
represent: representYamlFloat,
|
|
3460
|
+
resolve: resolveYamlFloat
|
|
3461
|
+
};
|
|
3462
|
+
|
|
3463
|
+
// __mcpc__cli_latest/node_modules/@jsr/std__yaml/_type/int.js
|
|
3464
|
+
function isCharCodeInRange(c, lower, upper) {
|
|
3465
|
+
return lower <= c && c <= upper;
|
|
3466
|
+
}
|
|
3467
|
+
function isHexCode(c) {
|
|
3468
|
+
return isCharCodeInRange(c, 48, 57) || // 0-9
|
|
3469
|
+
isCharCodeInRange(c, 65, 70) || // A-F
|
|
3470
|
+
isCharCodeInRange(c, 97, 102);
|
|
3471
|
+
}
|
|
3472
|
+
function isOctCode(c) {
|
|
3473
|
+
return isCharCodeInRange(c, 48, 55);
|
|
3474
|
+
}
|
|
3475
|
+
function isDecCode(c) {
|
|
3476
|
+
return isCharCodeInRange(c, 48, 57);
|
|
3477
|
+
}
|
|
3478
|
+
function resolveYamlInteger(data) {
|
|
3479
|
+
const max = data.length;
|
|
3480
|
+
let index = 0;
|
|
3481
|
+
let hasDigits = false;
|
|
3482
|
+
if (!max) return false;
|
|
3483
|
+
let ch = data[index];
|
|
3484
|
+
if (ch === "-" || ch === "+") {
|
|
3485
|
+
ch = data[++index];
|
|
3486
|
+
}
|
|
3487
|
+
if (ch === "0") {
|
|
3488
|
+
if (index + 1 === max) return true;
|
|
3489
|
+
ch = data[++index];
|
|
3490
|
+
if (ch === "b") {
|
|
3491
|
+
index++;
|
|
3492
|
+
for (; index < max; index++) {
|
|
3493
|
+
ch = data[index];
|
|
3494
|
+
if (ch === "_") continue;
|
|
3495
|
+
if (ch !== "0" && ch !== "1") return false;
|
|
3496
|
+
hasDigits = true;
|
|
3497
|
+
}
|
|
3498
|
+
return hasDigits && ch !== "_";
|
|
3499
|
+
}
|
|
3500
|
+
if (ch === "x") {
|
|
3501
|
+
index++;
|
|
3502
|
+
for (; index < max; index++) {
|
|
3503
|
+
ch = data[index];
|
|
3504
|
+
if (ch === "_") continue;
|
|
3505
|
+
if (!isHexCode(data.charCodeAt(index))) return false;
|
|
3506
|
+
hasDigits = true;
|
|
3507
|
+
}
|
|
3508
|
+
return hasDigits && ch !== "_";
|
|
3509
|
+
}
|
|
3510
|
+
for (; index < max; index++) {
|
|
3511
|
+
ch = data[index];
|
|
3512
|
+
if (ch === "_") continue;
|
|
3513
|
+
if (!isOctCode(data.charCodeAt(index))) return false;
|
|
3514
|
+
hasDigits = true;
|
|
3515
|
+
}
|
|
3516
|
+
return hasDigits && ch !== "_";
|
|
3517
|
+
}
|
|
3518
|
+
if (ch === "_") return false;
|
|
3519
|
+
for (; index < max; index++) {
|
|
3520
|
+
ch = data[index];
|
|
3521
|
+
if (ch === "_") continue;
|
|
3522
|
+
if (!isDecCode(data.charCodeAt(index))) {
|
|
3523
|
+
return false;
|
|
3524
|
+
}
|
|
3525
|
+
hasDigits = true;
|
|
3526
|
+
}
|
|
3527
|
+
if (!hasDigits || ch === "_") return false;
|
|
3528
|
+
return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
|
|
3529
|
+
}
|
|
3530
|
+
function constructYamlInteger(data) {
|
|
3531
|
+
let value = data;
|
|
3532
|
+
if (value.includes("_")) {
|
|
3533
|
+
value = value.replace(/_/g, "");
|
|
3534
|
+
}
|
|
3535
|
+
let sign = 1;
|
|
3536
|
+
let ch = value[0];
|
|
3537
|
+
if (ch === "-" || ch === "+") {
|
|
3538
|
+
if (ch === "-") sign = -1;
|
|
3539
|
+
value = value.slice(1);
|
|
3540
|
+
ch = value[0];
|
|
3541
|
+
}
|
|
3542
|
+
if (value === "0") return 0;
|
|
3543
|
+
if (ch === "0") {
|
|
3544
|
+
if (value[1] === "b") return sign * parseInt(value.slice(2), 2);
|
|
3545
|
+
if (value[1] === "x") return sign * parseInt(value, 16);
|
|
3546
|
+
return sign * parseInt(value, 8);
|
|
3547
|
+
}
|
|
3548
|
+
return sign * parseInt(value, 10);
|
|
3549
|
+
}
|
|
3550
|
+
function isInteger(object5) {
|
|
3551
|
+
if (object5 instanceof Number) object5 = object5.valueOf();
|
|
3552
|
+
return typeof object5 === "number" && object5 % 1 === 0 && !isNegativeZero(object5);
|
|
3553
|
+
}
|
|
3554
|
+
var int = {
|
|
3555
|
+
tag: "tag:yaml.org,2002:int",
|
|
3556
|
+
construct: constructYamlInteger,
|
|
3557
|
+
defaultStyle: "decimal",
|
|
3558
|
+
kind: "scalar",
|
|
3559
|
+
predicate: isInteger,
|
|
3560
|
+
represent: {
|
|
3561
|
+
// deno-lint-ignore ban-types
|
|
3562
|
+
binary(object5) {
|
|
3563
|
+
const value = object5 instanceof Number ? object5.valueOf() : object5;
|
|
3564
|
+
return value >= 0 ? `0b${value.toString(2)}` : `-0b${value.toString(2).slice(1)}`;
|
|
3565
|
+
},
|
|
3566
|
+
// deno-lint-ignore ban-types
|
|
3567
|
+
octal(object5) {
|
|
3568
|
+
const value = object5 instanceof Number ? object5.valueOf() : object5;
|
|
3569
|
+
return value >= 0 ? `0${value.toString(8)}` : `-0${value.toString(8).slice(1)}`;
|
|
3570
|
+
},
|
|
3571
|
+
// deno-lint-ignore ban-types
|
|
3572
|
+
decimal(object5) {
|
|
3573
|
+
const value = object5 instanceof Number ? object5.valueOf() : object5;
|
|
3574
|
+
return value.toString(10);
|
|
3575
|
+
},
|
|
3576
|
+
// deno-lint-ignore ban-types
|
|
3577
|
+
hexadecimal(object5) {
|
|
3578
|
+
const value = object5 instanceof Number ? object5.valueOf() : object5;
|
|
3579
|
+
return value >= 0 ? `0x${value.toString(16).toUpperCase()}` : `-0x${value.toString(16).toUpperCase().slice(1)}`;
|
|
3580
|
+
}
|
|
3581
|
+
},
|
|
3582
|
+
resolve: resolveYamlInteger
|
|
3583
|
+
};
|
|
3584
|
+
|
|
3585
|
+
// __mcpc__cli_latest/node_modules/@jsr/std__yaml/_type/map.js
|
|
3586
|
+
var map = {
|
|
3587
|
+
tag: "tag:yaml.org,2002:map",
|
|
3588
|
+
resolve() {
|
|
3589
|
+
return true;
|
|
3590
|
+
},
|
|
3591
|
+
construct(data) {
|
|
3592
|
+
return data !== null ? data : {};
|
|
3593
|
+
},
|
|
3594
|
+
kind: "mapping"
|
|
3595
|
+
};
|
|
3596
|
+
|
|
3597
|
+
// __mcpc__cli_latest/node_modules/@jsr/std__yaml/_type/merge.js
|
|
3598
|
+
var merge = {
|
|
3599
|
+
tag: "tag:yaml.org,2002:merge",
|
|
3600
|
+
kind: "scalar",
|
|
3601
|
+
resolve: (data) => data === "<<" || data === null,
|
|
3602
|
+
construct: (data) => data
|
|
3603
|
+
};
|
|
3604
|
+
|
|
3605
|
+
// __mcpc__cli_latest/node_modules/@jsr/std__yaml/_type/nil.js
|
|
3606
|
+
var nil = {
|
|
3607
|
+
tag: "tag:yaml.org,2002:null",
|
|
3608
|
+
kind: "scalar",
|
|
3609
|
+
defaultStyle: "lowercase",
|
|
3610
|
+
predicate: (object5) => object5 === null,
|
|
3611
|
+
construct: () => null,
|
|
3612
|
+
resolve: (data) => {
|
|
3613
|
+
return data === "~" || data === "null" || data === "Null" || data === "NULL";
|
|
3614
|
+
},
|
|
3615
|
+
represent: {
|
|
3616
|
+
lowercase: () => "null",
|
|
3617
|
+
uppercase: () => "NULL",
|
|
3618
|
+
camelcase: () => "Null"
|
|
3619
|
+
}
|
|
3620
|
+
};
|
|
3621
|
+
|
|
3622
|
+
// __mcpc__cli_latest/node_modules/@jsr/std__yaml/_type/omap.js
|
|
3623
|
+
function resolveYamlOmap(data) {
|
|
3624
|
+
const objectKeys = /* @__PURE__ */ new Set();
|
|
3625
|
+
for (const object5 of data) {
|
|
3626
|
+
if (!isPlainObject(object5)) return false;
|
|
3627
|
+
const keys = Object.keys(object5);
|
|
3628
|
+
if (keys.length !== 1) return false;
|
|
3629
|
+
for (const key of keys) {
|
|
3630
|
+
if (objectKeys.has(key)) return false;
|
|
3631
|
+
objectKeys.add(key);
|
|
3632
|
+
}
|
|
3633
|
+
}
|
|
3634
|
+
return true;
|
|
3635
|
+
}
|
|
3636
|
+
var omap = {
|
|
3637
|
+
tag: "tag:yaml.org,2002:omap",
|
|
3638
|
+
kind: "sequence",
|
|
3639
|
+
resolve: resolveYamlOmap,
|
|
3640
|
+
construct(data) {
|
|
3641
|
+
return data;
|
|
3642
|
+
}
|
|
3643
|
+
};
|
|
3644
|
+
|
|
3645
|
+
// __mcpc__cli_latest/node_modules/@jsr/std__yaml/_type/pairs.js
|
|
3646
|
+
function resolveYamlPairs(data) {
|
|
3647
|
+
if (data === null) return true;
|
|
3648
|
+
return data.every((it) => isPlainObject(it) && Object.keys(it).length === 1);
|
|
3649
|
+
}
|
|
3650
|
+
var pairs = {
|
|
3651
|
+
tag: "tag:yaml.org,2002:pairs",
|
|
3652
|
+
construct(data) {
|
|
3653
|
+
return data?.flatMap(Object.entries) ?? [];
|
|
3654
|
+
},
|
|
3655
|
+
kind: "sequence",
|
|
3656
|
+
resolve: resolveYamlPairs
|
|
3657
|
+
};
|
|
3658
|
+
|
|
3659
|
+
// __mcpc__cli_latest/node_modules/@jsr/std__yaml/_type/regexp.js
|
|
3660
|
+
var REGEXP = /^\/(?<regexp>[\s\S]+)\/(?<modifiers>[gismuy]*)$/;
|
|
3661
|
+
var regexp = {
|
|
3662
|
+
tag: "tag:yaml.org,2002:js/regexp",
|
|
3663
|
+
kind: "scalar",
|
|
3664
|
+
resolve(data) {
|
|
3665
|
+
if (data === null || !data.length) return false;
|
|
3666
|
+
if (data.charAt(0) === "/") {
|
|
3667
|
+
const groups = data.match(REGEXP)?.groups;
|
|
3668
|
+
if (!groups) return false;
|
|
3669
|
+
const modifiers = groups.modifiers ?? "";
|
|
3670
|
+
if (new Set(modifiers).size < modifiers.length) return false;
|
|
3671
|
+
}
|
|
3672
|
+
return true;
|
|
3673
|
+
},
|
|
3674
|
+
construct(data) {
|
|
3675
|
+
const { regexp: regexp2 = data, modifiers = "" } = data.match(REGEXP)?.groups ?? {};
|
|
3676
|
+
return new RegExp(regexp2, modifiers);
|
|
3677
|
+
},
|
|
3678
|
+
predicate: (object5) => object5 instanceof RegExp,
|
|
3679
|
+
represent: (object5) => object5.toString()
|
|
3680
|
+
};
|
|
3681
|
+
|
|
3682
|
+
// __mcpc__cli_latest/node_modules/@jsr/std__yaml/_type/seq.js
|
|
3683
|
+
var seq = {
|
|
3684
|
+
tag: "tag:yaml.org,2002:seq",
|
|
3685
|
+
kind: "sequence",
|
|
3686
|
+
resolve: () => true,
|
|
3687
|
+
construct: (data) => data !== null ? data : []
|
|
3688
|
+
};
|
|
3689
|
+
|
|
3690
|
+
// __mcpc__cli_latest/node_modules/@jsr/std__yaml/_type/set.js
|
|
3691
|
+
var set = {
|
|
3692
|
+
tag: "tag:yaml.org,2002:set",
|
|
3693
|
+
kind: "mapping",
|
|
3694
|
+
construct: (data) => data !== null ? data : {},
|
|
3695
|
+
resolve: (data) => {
|
|
3696
|
+
if (data === null) return true;
|
|
3697
|
+
return Object.values(data).every((it) => it === null);
|
|
3698
|
+
}
|
|
3699
|
+
};
|
|
3700
|
+
|
|
3701
|
+
// __mcpc__cli_latest/node_modules/@jsr/std__yaml/_type/str.js
|
|
3702
|
+
var str = {
|
|
3703
|
+
tag: "tag:yaml.org,2002:str",
|
|
3704
|
+
kind: "scalar",
|
|
3705
|
+
resolve: () => true,
|
|
3706
|
+
construct: (data) => data !== null ? data : ""
|
|
3707
|
+
};
|
|
3708
|
+
|
|
3709
|
+
// __mcpc__cli_latest/node_modules/@jsr/std__yaml/_type/timestamp.js
|
|
3710
|
+
var YAML_DATE_REGEXP = new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$");
|
|
3711
|
+
var YAML_TIMESTAMP_REGEXP = new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");
|
|
3712
|
+
function resolveYamlTimestamp(data) {
|
|
3713
|
+
if (data === null) return false;
|
|
3714
|
+
if (YAML_DATE_REGEXP.exec(data) !== null) return true;
|
|
3715
|
+
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
|
|
3716
|
+
return false;
|
|
3717
|
+
}
|
|
3718
|
+
function constructYamlTimestamp(data) {
|
|
3719
|
+
let match = YAML_DATE_REGEXP.exec(data);
|
|
3720
|
+
if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
|
|
3721
|
+
if (match === null) {
|
|
3722
|
+
throw new Error("Cannot construct YAML timestamp: date resolve error");
|
|
3723
|
+
}
|
|
3724
|
+
const year = +match[1];
|
|
3725
|
+
const month = +match[2] - 1;
|
|
3726
|
+
const day = +match[3];
|
|
3727
|
+
if (!match[4]) {
|
|
3728
|
+
return new Date(Date.UTC(year, month, day));
|
|
3729
|
+
}
|
|
3730
|
+
const hour = +match[4];
|
|
3731
|
+
const minute = +match[5];
|
|
3732
|
+
const second = +match[6];
|
|
3733
|
+
let fraction = 0;
|
|
3734
|
+
if (match[7]) {
|
|
3735
|
+
let partFraction = match[7].slice(0, 3);
|
|
3736
|
+
while (partFraction.length < 3) {
|
|
3737
|
+
partFraction += "0";
|
|
3738
|
+
}
|
|
3739
|
+
fraction = +partFraction;
|
|
3740
|
+
}
|
|
3741
|
+
let delta = null;
|
|
3742
|
+
if (match[9] && match[10]) {
|
|
3743
|
+
const tzHour = +match[10];
|
|
3744
|
+
const tzMinute = +(match[11] || 0);
|
|
3745
|
+
delta = (tzHour * 60 + tzMinute) * 6e4;
|
|
3746
|
+
if (match[9] === "-") delta = -delta;
|
|
3747
|
+
}
|
|
3748
|
+
const date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
3749
|
+
if (delta) date.setTime(date.getTime() - delta);
|
|
3750
|
+
return date;
|
|
3751
|
+
}
|
|
3752
|
+
function representYamlTimestamp(date) {
|
|
3753
|
+
return date.toISOString();
|
|
3754
|
+
}
|
|
3755
|
+
var timestamp = {
|
|
3756
|
+
tag: "tag:yaml.org,2002:timestamp",
|
|
3757
|
+
construct: constructYamlTimestamp,
|
|
3758
|
+
predicate(object5) {
|
|
3759
|
+
return object5 instanceof Date;
|
|
3760
|
+
},
|
|
3761
|
+
kind: "scalar",
|
|
3762
|
+
represent: representYamlTimestamp,
|
|
3763
|
+
resolve: resolveYamlTimestamp
|
|
3764
|
+
};
|
|
3765
|
+
|
|
3766
|
+
// __mcpc__cli_latest/node_modules/@jsr/std__yaml/_type/undefined.js
|
|
3767
|
+
var undefinedType = {
|
|
3768
|
+
tag: "tag:yaml.org,2002:js/undefined",
|
|
3769
|
+
kind: "scalar",
|
|
3770
|
+
resolve() {
|
|
3771
|
+
return true;
|
|
3772
|
+
},
|
|
3773
|
+
construct() {
|
|
3774
|
+
return void 0;
|
|
3775
|
+
},
|
|
3776
|
+
predicate(object5) {
|
|
3777
|
+
return typeof object5 === "undefined";
|
|
3778
|
+
},
|
|
3779
|
+
represent() {
|
|
3780
|
+
return "";
|
|
3781
|
+
}
|
|
3782
|
+
};
|
|
3783
|
+
|
|
3784
|
+
// __mcpc__cli_latest/node_modules/@jsr/std__yaml/_schema.js
|
|
3785
|
+
function createTypeMap(implicitTypes, explicitTypes) {
|
|
3786
|
+
const result = {
|
|
3787
|
+
fallback: /* @__PURE__ */ new Map(),
|
|
3788
|
+
mapping: /* @__PURE__ */ new Map(),
|
|
3789
|
+
scalar: /* @__PURE__ */ new Map(),
|
|
3790
|
+
sequence: /* @__PURE__ */ new Map()
|
|
3791
|
+
};
|
|
3792
|
+
const fallbackMap = result.fallback;
|
|
3793
|
+
for (const type of [
|
|
3794
|
+
...implicitTypes,
|
|
3795
|
+
...explicitTypes
|
|
3796
|
+
]) {
|
|
3797
|
+
const map2 = result[type.kind];
|
|
3798
|
+
map2.set(type.tag, type);
|
|
3799
|
+
fallbackMap.set(type.tag, type);
|
|
3800
|
+
}
|
|
3801
|
+
return result;
|
|
3802
|
+
}
|
|
3803
|
+
function createSchema({ explicitTypes = [], implicitTypes = [], include }) {
|
|
3804
|
+
if (include) {
|
|
3805
|
+
implicitTypes.push(...include.implicitTypes);
|
|
3806
|
+
explicitTypes.push(...include.explicitTypes);
|
|
3807
|
+
}
|
|
3808
|
+
const typeMap = createTypeMap(implicitTypes, explicitTypes);
|
|
3809
|
+
return {
|
|
3810
|
+
implicitTypes,
|
|
3811
|
+
explicitTypes,
|
|
3812
|
+
typeMap
|
|
3813
|
+
};
|
|
3814
|
+
}
|
|
3815
|
+
var FAILSAFE_SCHEMA = createSchema({
|
|
3816
|
+
explicitTypes: [
|
|
3817
|
+
str,
|
|
3818
|
+
seq,
|
|
3819
|
+
map
|
|
3820
|
+
]
|
|
3821
|
+
});
|
|
3822
|
+
var JSON_SCHEMA = createSchema({
|
|
3823
|
+
implicitTypes: [
|
|
3824
|
+
nil,
|
|
3825
|
+
bool,
|
|
3826
|
+
int,
|
|
3827
|
+
float
|
|
3828
|
+
],
|
|
3829
|
+
include: FAILSAFE_SCHEMA
|
|
3830
|
+
});
|
|
3831
|
+
var CORE_SCHEMA = createSchema({
|
|
3832
|
+
include: JSON_SCHEMA
|
|
3833
|
+
});
|
|
3834
|
+
var DEFAULT_SCHEMA = createSchema({
|
|
3835
|
+
explicitTypes: [
|
|
3836
|
+
binary,
|
|
3837
|
+
omap,
|
|
3838
|
+
pairs,
|
|
3839
|
+
set
|
|
3840
|
+
],
|
|
3841
|
+
implicitTypes: [
|
|
3842
|
+
timestamp,
|
|
3843
|
+
merge
|
|
3844
|
+
],
|
|
3845
|
+
include: CORE_SCHEMA
|
|
3846
|
+
});
|
|
3847
|
+
var EXTENDED_SCHEMA = createSchema({
|
|
3848
|
+
explicitTypes: [
|
|
3849
|
+
regexp,
|
|
3850
|
+
undefinedType
|
|
3851
|
+
],
|
|
3852
|
+
include: DEFAULT_SCHEMA
|
|
3853
|
+
});
|
|
3854
|
+
var SCHEMA_MAP = /* @__PURE__ */ new Map([
|
|
3855
|
+
[
|
|
3856
|
+
"core",
|
|
3857
|
+
CORE_SCHEMA
|
|
3858
|
+
],
|
|
3859
|
+
[
|
|
3860
|
+
"default",
|
|
3861
|
+
DEFAULT_SCHEMA
|
|
3862
|
+
],
|
|
3863
|
+
[
|
|
3864
|
+
"failsafe",
|
|
3865
|
+
FAILSAFE_SCHEMA
|
|
3866
|
+
],
|
|
3867
|
+
[
|
|
3868
|
+
"json",
|
|
3869
|
+
JSON_SCHEMA
|
|
3870
|
+
],
|
|
3871
|
+
[
|
|
3872
|
+
"extended",
|
|
3873
|
+
EXTENDED_SCHEMA
|
|
3874
|
+
]
|
|
3875
|
+
]);
|
|
3876
|
+
|
|
3877
|
+
// __mcpc__cli_latest/node_modules/@jsr/std__yaml/_loader_state.js
|
|
3878
|
+
var CONTEXT_FLOW_IN = 1;
|
|
3879
|
+
var CONTEXT_FLOW_OUT = 2;
|
|
3880
|
+
var CONTEXT_BLOCK_IN = 3;
|
|
3881
|
+
var CONTEXT_BLOCK_OUT = 4;
|
|
3882
|
+
var CHOMPING_CLIP = 1;
|
|
3883
|
+
var CHOMPING_STRIP = 2;
|
|
3884
|
+
var CHOMPING_KEEP = 3;
|
|
3885
|
+
var PATTERN_NON_PRINTABLE = (
|
|
3886
|
+
// deno-lint-ignore no-control-regex
|
|
3887
|
+
/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/
|
|
3888
|
+
);
|
|
3889
|
+
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
|
3890
|
+
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
|
3891
|
+
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
|
3892
|
+
var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
|
|
3893
|
+
var ESCAPED_HEX_LENGTHS = /* @__PURE__ */ new Map([
|
|
3894
|
+
[
|
|
3895
|
+
120,
|
|
3896
|
+
2
|
|
3897
|
+
],
|
|
3898
|
+
[
|
|
3899
|
+
117,
|
|
3900
|
+
4
|
|
3901
|
+
],
|
|
3902
|
+
[
|
|
3903
|
+
85,
|
|
3904
|
+
8
|
|
3905
|
+
]
|
|
3906
|
+
]);
|
|
3907
|
+
var SIMPLE_ESCAPE_SEQUENCES = /* @__PURE__ */ new Map([
|
|
3908
|
+
[
|
|
3909
|
+
48,
|
|
3910
|
+
"\0"
|
|
3911
|
+
],
|
|
3912
|
+
[
|
|
3913
|
+
97,
|
|
3914
|
+
"\x07"
|
|
3915
|
+
],
|
|
3916
|
+
[
|
|
3917
|
+
98,
|
|
3918
|
+
"\b"
|
|
3919
|
+
],
|
|
3920
|
+
[
|
|
3921
|
+
116,
|
|
3922
|
+
" "
|
|
3923
|
+
],
|
|
3924
|
+
[
|
|
3925
|
+
9,
|
|
3926
|
+
" "
|
|
3927
|
+
],
|
|
3928
|
+
[
|
|
3929
|
+
110,
|
|
3930
|
+
"\n"
|
|
3931
|
+
],
|
|
3932
|
+
[
|
|
3933
|
+
118,
|
|
3934
|
+
"\v"
|
|
3935
|
+
],
|
|
3936
|
+
[
|
|
3937
|
+
102,
|
|
3938
|
+
"\f"
|
|
3939
|
+
],
|
|
3940
|
+
[
|
|
3941
|
+
114,
|
|
3942
|
+
"\r"
|
|
3943
|
+
],
|
|
3944
|
+
[
|
|
3945
|
+
101,
|
|
3946
|
+
"\x1B"
|
|
3947
|
+
],
|
|
3948
|
+
[
|
|
3949
|
+
32,
|
|
3950
|
+
" "
|
|
3951
|
+
],
|
|
3952
|
+
[
|
|
3953
|
+
34,
|
|
3954
|
+
'"'
|
|
3955
|
+
],
|
|
3956
|
+
[
|
|
3957
|
+
47,
|
|
3958
|
+
"/"
|
|
3959
|
+
],
|
|
3960
|
+
[
|
|
3961
|
+
92,
|
|
3962
|
+
"\\"
|
|
3963
|
+
],
|
|
3964
|
+
[
|
|
3965
|
+
78,
|
|
3966
|
+
"\x85"
|
|
3967
|
+
],
|
|
3968
|
+
[
|
|
3969
|
+
95,
|
|
3970
|
+
"\xA0"
|
|
3971
|
+
],
|
|
3972
|
+
[
|
|
3973
|
+
76,
|
|
3974
|
+
"\u2028"
|
|
3975
|
+
],
|
|
3976
|
+
[
|
|
3977
|
+
80,
|
|
3978
|
+
"\u2029"
|
|
3979
|
+
]
|
|
3980
|
+
]);
|
|
3981
|
+
function hexCharCodeToNumber(charCode) {
|
|
3982
|
+
if (48 <= charCode && charCode <= 57) return charCode - 48;
|
|
3983
|
+
const lc = charCode | 32;
|
|
3984
|
+
if (97 <= lc && lc <= 102) return lc - 97 + 10;
|
|
3985
|
+
return -1;
|
|
3986
|
+
}
|
|
3987
|
+
function decimalCharCodeToNumber(charCode) {
|
|
3988
|
+
if (48 <= charCode && charCode <= 57) return charCode - 48;
|
|
3989
|
+
return -1;
|
|
3990
|
+
}
|
|
3991
|
+
function codepointToChar(codepoint) {
|
|
3992
|
+
if (codepoint <= 65535) return String.fromCharCode(codepoint);
|
|
3993
|
+
return String.fromCharCode((codepoint - 65536 >> 10) + 55296, (codepoint - 65536 & 1023) + 56320);
|
|
3994
|
+
}
|
|
3995
|
+
var INDENT = 4;
|
|
3996
|
+
var MAX_LENGTH = 75;
|
|
3997
|
+
var DELIMITERS = "\0\r\n\x85\u2028\u2029";
|
|
3998
|
+
function getSnippet(buffer, position) {
|
|
3999
|
+
if (!buffer) return null;
|
|
4000
|
+
let start = position;
|
|
4001
|
+
let end = position;
|
|
4002
|
+
let head = "";
|
|
4003
|
+
let tail = "";
|
|
4004
|
+
while (start > 0 && !DELIMITERS.includes(buffer.charAt(start - 1))) {
|
|
4005
|
+
start--;
|
|
4006
|
+
if (position - start > MAX_LENGTH / 2 - 1) {
|
|
4007
|
+
head = " ... ";
|
|
4008
|
+
start += 5;
|
|
4009
|
+
break;
|
|
4010
|
+
}
|
|
4011
|
+
}
|
|
4012
|
+
while (end < buffer.length && !DELIMITERS.includes(buffer.charAt(end))) {
|
|
4013
|
+
end++;
|
|
4014
|
+
if (end - position > MAX_LENGTH / 2 - 1) {
|
|
4015
|
+
tail = " ... ";
|
|
4016
|
+
end -= 5;
|
|
4017
|
+
break;
|
|
4018
|
+
}
|
|
4019
|
+
}
|
|
4020
|
+
const snippet = buffer.slice(start, end);
|
|
4021
|
+
const indent = " ".repeat(INDENT);
|
|
4022
|
+
const caretIndent = " ".repeat(INDENT + position - start + head.length);
|
|
4023
|
+
return `${indent + head + snippet + tail}
|
|
4024
|
+
${caretIndent}^`;
|
|
4025
|
+
}
|
|
4026
|
+
function markToString(buffer, position, line, column) {
|
|
4027
|
+
let where = `at line ${line + 1}, column ${column + 1}`;
|
|
4028
|
+
const snippet = getSnippet(buffer, position);
|
|
4029
|
+
if (snippet) where += `:
|
|
4030
|
+
${snippet}`;
|
|
4031
|
+
return where;
|
|
4032
|
+
}
|
|
4033
|
+
function getIndentStatus(lineIndent, parentIndent) {
|
|
4034
|
+
if (lineIndent > parentIndent) return 1;
|
|
4035
|
+
if (lineIndent < parentIndent) return -1;
|
|
4036
|
+
return 0;
|
|
4037
|
+
}
|
|
4038
|
+
function writeFoldedLines(count) {
|
|
4039
|
+
if (count === 1) return " ";
|
|
4040
|
+
if (count > 1) return "\n".repeat(count - 1);
|
|
4041
|
+
return "";
|
|
4042
|
+
}
|
|
4043
|
+
var LoaderState = class {
|
|
4044
|
+
input;
|
|
4045
|
+
length;
|
|
4046
|
+
lineIndent = 0;
|
|
4047
|
+
lineStart = 0;
|
|
4048
|
+
position = 0;
|
|
4049
|
+
line = 0;
|
|
4050
|
+
onWarning;
|
|
4051
|
+
allowDuplicateKeys;
|
|
4052
|
+
implicitTypes;
|
|
4053
|
+
typeMap;
|
|
4054
|
+
checkLineBreaks = false;
|
|
4055
|
+
tagMap = /* @__PURE__ */ new Map();
|
|
4056
|
+
anchorMap = /* @__PURE__ */ new Map();
|
|
4057
|
+
constructor(input, { schema = DEFAULT_SCHEMA, onWarning, allowDuplicateKeys = false }) {
|
|
4058
|
+
this.input = input;
|
|
4059
|
+
this.onWarning = onWarning;
|
|
4060
|
+
this.allowDuplicateKeys = allowDuplicateKeys;
|
|
4061
|
+
this.implicitTypes = schema.implicitTypes;
|
|
4062
|
+
this.typeMap = schema.typeMap;
|
|
4063
|
+
this.length = input.length;
|
|
4064
|
+
this.readIndent();
|
|
4065
|
+
}
|
|
4066
|
+
skipWhitespaces() {
|
|
4067
|
+
let ch = this.peek();
|
|
4068
|
+
while (isWhiteSpace(ch)) {
|
|
4069
|
+
ch = this.next();
|
|
4070
|
+
}
|
|
4071
|
+
}
|
|
4072
|
+
skipComment() {
|
|
4073
|
+
let ch = this.peek();
|
|
4074
|
+
if (ch !== SHARP) return;
|
|
4075
|
+
ch = this.next();
|
|
4076
|
+
while (ch !== 0 && !isEOL(ch)) {
|
|
4077
|
+
ch = this.next();
|
|
4078
|
+
}
|
|
4079
|
+
}
|
|
4080
|
+
readIndent() {
|
|
4081
|
+
let char = this.peek();
|
|
4082
|
+
while (char === SPACE) {
|
|
4083
|
+
this.lineIndent += 1;
|
|
4084
|
+
char = this.next();
|
|
4085
|
+
}
|
|
4086
|
+
}
|
|
4087
|
+
peek(offset = 0) {
|
|
4088
|
+
return this.input.charCodeAt(this.position + offset);
|
|
4089
|
+
}
|
|
4090
|
+
next() {
|
|
4091
|
+
this.position += 1;
|
|
4092
|
+
return this.peek();
|
|
4093
|
+
}
|
|
4094
|
+
#createError(message) {
|
|
4095
|
+
const mark = markToString(this.input, this.position, this.line, this.position - this.lineStart);
|
|
4096
|
+
return new SyntaxError(`${message} ${mark}`);
|
|
4097
|
+
}
|
|
4098
|
+
dispatchWarning(message) {
|
|
4099
|
+
const error = this.#createError(message);
|
|
4100
|
+
this.onWarning?.(error);
|
|
4101
|
+
}
|
|
4102
|
+
yamlDirectiveHandler(args) {
|
|
4103
|
+
if (args.length !== 1) {
|
|
4104
|
+
throw this.#createError("Cannot handle YAML directive: YAML directive accepts exactly one argument");
|
|
4105
|
+
}
|
|
4106
|
+
const match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
|
4107
|
+
if (match === null) {
|
|
4108
|
+
throw this.#createError("Cannot handle YAML directive: ill-formed argument");
|
|
4109
|
+
}
|
|
4110
|
+
const major = parseInt(match[1], 10);
|
|
4111
|
+
const minor = parseInt(match[2], 10);
|
|
4112
|
+
if (major !== 1) {
|
|
4113
|
+
throw this.#createError("Cannot handle YAML directive: unacceptable YAML version");
|
|
4114
|
+
}
|
|
4115
|
+
this.checkLineBreaks = minor < 2;
|
|
4116
|
+
if (minor !== 1 && minor !== 2) {
|
|
4117
|
+
this.dispatchWarning("Cannot handle YAML directive: unsupported YAML version");
|
|
4118
|
+
}
|
|
4119
|
+
return args[0] ?? null;
|
|
4120
|
+
}
|
|
4121
|
+
tagDirectiveHandler(args) {
|
|
4122
|
+
if (args.length !== 2) {
|
|
4123
|
+
throw this.#createError(`Cannot handle tag directive: directive accepts exactly two arguments, received ${args.length}`);
|
|
4124
|
+
}
|
|
4125
|
+
const handle = args[0];
|
|
4126
|
+
const prefix = args[1];
|
|
4127
|
+
if (!PATTERN_TAG_HANDLE.test(handle)) {
|
|
4128
|
+
throw this.#createError(`Cannot handle tag directive: ill-formed handle (first argument) in "${handle}"`);
|
|
4129
|
+
}
|
|
4130
|
+
if (this.tagMap.has(handle)) {
|
|
4131
|
+
throw this.#createError(`Cannot handle tag directive: previously declared suffix for "${handle}" tag handle`);
|
|
4132
|
+
}
|
|
4133
|
+
if (!PATTERN_TAG_URI.test(prefix)) {
|
|
4134
|
+
throw this.#createError("Cannot handle tag directive: ill-formed tag prefix (second argument) of the TAG directive");
|
|
4135
|
+
}
|
|
4136
|
+
this.tagMap.set(handle, prefix);
|
|
4137
|
+
}
|
|
4138
|
+
captureSegment(start, end, checkJson) {
|
|
4139
|
+
if (start < end) {
|
|
4140
|
+
const result = this.input.slice(start, end);
|
|
4141
|
+
if (checkJson) {
|
|
4142
|
+
for (let position = 0; position < result.length; position++) {
|
|
4143
|
+
const character = result.charCodeAt(position);
|
|
4144
|
+
if (!(character === 9 || 32 <= character && character <= 1114111)) {
|
|
4145
|
+
throw this.#createError(`Expected valid JSON character: received "${character}"`);
|
|
4146
|
+
}
|
|
4147
|
+
}
|
|
4148
|
+
} else if (PATTERN_NON_PRINTABLE.test(result)) {
|
|
4149
|
+
throw this.#createError("Stream contains non-printable characters");
|
|
4150
|
+
}
|
|
4151
|
+
return result;
|
|
4152
|
+
}
|
|
4153
|
+
}
|
|
4154
|
+
readBlockSequence(tag, anchor, nodeIndent) {
|
|
4155
|
+
let detected = false;
|
|
4156
|
+
const result = [];
|
|
4157
|
+
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
4158
|
+
let ch = this.peek();
|
|
4159
|
+
while (ch !== 0) {
|
|
4160
|
+
if (ch !== MINUS) {
|
|
4161
|
+
break;
|
|
4162
|
+
}
|
|
4163
|
+
const following = this.peek(1);
|
|
4164
|
+
if (!isWhiteSpaceOrEOL(following)) {
|
|
4165
|
+
break;
|
|
4166
|
+
}
|
|
4167
|
+
detected = true;
|
|
4168
|
+
this.position++;
|
|
4169
|
+
if (this.skipSeparationSpace(true, -1)) {
|
|
4170
|
+
if (this.lineIndent <= nodeIndent) {
|
|
4171
|
+
result.push(null);
|
|
4172
|
+
ch = this.peek();
|
|
4173
|
+
continue;
|
|
4174
|
+
}
|
|
4175
|
+
}
|
|
4176
|
+
const line = this.line;
|
|
4177
|
+
const newState = this.composeNode({
|
|
4178
|
+
parentIndent: nodeIndent,
|
|
4179
|
+
nodeContext: CONTEXT_BLOCK_IN,
|
|
4180
|
+
allowToSeek: false,
|
|
4181
|
+
allowCompact: true
|
|
4182
|
+
});
|
|
4183
|
+
if (newState) result.push(newState.result);
|
|
4184
|
+
this.skipSeparationSpace(true, -1);
|
|
4185
|
+
ch = this.peek();
|
|
4186
|
+
if ((this.line === line || this.lineIndent > nodeIndent) && ch !== 0) {
|
|
4187
|
+
throw this.#createError("Cannot read block sequence: bad indentation of a sequence entry");
|
|
4188
|
+
} else if (this.lineIndent < nodeIndent) {
|
|
4189
|
+
break;
|
|
4190
|
+
}
|
|
4191
|
+
}
|
|
4192
|
+
if (detected) return {
|
|
4193
|
+
tag,
|
|
4194
|
+
anchor,
|
|
4195
|
+
kind: "sequence",
|
|
4196
|
+
result
|
|
4197
|
+
};
|
|
4198
|
+
}
|
|
4199
|
+
mergeMappings(destination, source, overridableKeys) {
|
|
4200
|
+
if (!isObject(source)) {
|
|
4201
|
+
throw this.#createError("Cannot merge mappings: the provided source object is unacceptable");
|
|
4202
|
+
}
|
|
4203
|
+
for (const [key, value] of Object.entries(source)) {
|
|
4204
|
+
if (Object.hasOwn(destination, key)) continue;
|
|
4205
|
+
Object.defineProperty(destination, key, {
|
|
4206
|
+
value,
|
|
4207
|
+
writable: true,
|
|
4208
|
+
enumerable: true,
|
|
4209
|
+
configurable: true
|
|
4210
|
+
});
|
|
4211
|
+
overridableKeys.add(key);
|
|
4212
|
+
}
|
|
4213
|
+
}
|
|
4214
|
+
storeMappingPair(result, overridableKeys, keyTag, keyNode, valueNode, startLine, startPos) {
|
|
4215
|
+
if (Array.isArray(keyNode)) {
|
|
4216
|
+
keyNode = Array.prototype.slice.call(keyNode);
|
|
4217
|
+
for (let index = 0; index < keyNode.length; index++) {
|
|
4218
|
+
if (Array.isArray(keyNode[index])) {
|
|
4219
|
+
throw this.#createError("Cannot store mapping pair: nested arrays are not supported inside keys");
|
|
4220
|
+
}
|
|
4221
|
+
if (typeof keyNode === "object" && isPlainObject(keyNode[index])) {
|
|
4222
|
+
keyNode[index] = "[object Object]";
|
|
4223
|
+
}
|
|
4224
|
+
}
|
|
4225
|
+
}
|
|
4226
|
+
if (typeof keyNode === "object" && isPlainObject(keyNode)) {
|
|
4227
|
+
keyNode = "[object Object]";
|
|
4228
|
+
}
|
|
4229
|
+
keyNode = String(keyNode);
|
|
4230
|
+
if (keyTag === "tag:yaml.org,2002:merge") {
|
|
4231
|
+
if (Array.isArray(valueNode)) {
|
|
4232
|
+
for (let index = 0; index < valueNode.length; index++) {
|
|
4233
|
+
this.mergeMappings(result, valueNode[index], overridableKeys);
|
|
4234
|
+
}
|
|
4235
|
+
} else {
|
|
4236
|
+
this.mergeMappings(result, valueNode, overridableKeys);
|
|
4237
|
+
}
|
|
4238
|
+
} else {
|
|
4239
|
+
if (!this.allowDuplicateKeys && !overridableKeys.has(keyNode) && Object.hasOwn(result, keyNode)) {
|
|
4240
|
+
this.line = startLine || this.line;
|
|
4241
|
+
this.position = startPos || this.position;
|
|
4242
|
+
throw this.#createError("Cannot store mapping pair: duplicated key");
|
|
4243
|
+
}
|
|
4244
|
+
Object.defineProperty(result, keyNode, {
|
|
4245
|
+
value: valueNode,
|
|
4246
|
+
writable: true,
|
|
4247
|
+
enumerable: true,
|
|
4248
|
+
configurable: true
|
|
4249
|
+
});
|
|
4250
|
+
overridableKeys.delete(keyNode);
|
|
4251
|
+
}
|
|
4252
|
+
return result;
|
|
4253
|
+
}
|
|
4254
|
+
readLineBreak() {
|
|
4255
|
+
const ch = this.peek();
|
|
4256
|
+
if (ch === LINE_FEED) {
|
|
4257
|
+
this.position++;
|
|
4258
|
+
} else if (ch === CARRIAGE_RETURN) {
|
|
4259
|
+
this.position++;
|
|
4260
|
+
if (this.peek() === LINE_FEED) {
|
|
4261
|
+
this.position++;
|
|
4262
|
+
}
|
|
4263
|
+
} else {
|
|
4264
|
+
throw this.#createError("Cannot read line: line break not found");
|
|
4265
|
+
}
|
|
4266
|
+
this.line += 1;
|
|
4267
|
+
this.lineStart = this.position;
|
|
4268
|
+
}
|
|
4269
|
+
skipSeparationSpace(allowComments, checkIndent) {
|
|
4270
|
+
let lineBreaks = 0;
|
|
4271
|
+
let ch = this.peek();
|
|
4272
|
+
while (ch !== 0) {
|
|
4273
|
+
this.skipWhitespaces();
|
|
4274
|
+
ch = this.peek();
|
|
4275
|
+
if (allowComments) {
|
|
4276
|
+
this.skipComment();
|
|
4277
|
+
ch = this.peek();
|
|
4278
|
+
}
|
|
4279
|
+
if (isEOL(ch)) {
|
|
4280
|
+
this.readLineBreak();
|
|
4281
|
+
ch = this.peek();
|
|
4282
|
+
lineBreaks++;
|
|
4283
|
+
this.lineIndent = 0;
|
|
4284
|
+
this.readIndent();
|
|
4285
|
+
ch = this.peek();
|
|
4286
|
+
} else {
|
|
4287
|
+
break;
|
|
4288
|
+
}
|
|
4289
|
+
}
|
|
4290
|
+
if (checkIndent !== -1 && lineBreaks !== 0 && this.lineIndent < checkIndent) {
|
|
4291
|
+
this.dispatchWarning("deficient indentation");
|
|
4292
|
+
}
|
|
4293
|
+
return lineBreaks;
|
|
4294
|
+
}
|
|
4295
|
+
testDocumentSeparator() {
|
|
4296
|
+
let ch = this.peek();
|
|
4297
|
+
if ((ch === MINUS || ch === DOT) && ch === this.peek(1) && ch === this.peek(2)) {
|
|
4298
|
+
ch = this.peek(3);
|
|
4299
|
+
if (ch === 0 || isWhiteSpaceOrEOL(ch)) {
|
|
4300
|
+
return true;
|
|
4301
|
+
}
|
|
4302
|
+
}
|
|
4303
|
+
return false;
|
|
4304
|
+
}
|
|
4305
|
+
readPlainScalar(tag, anchor, nodeIndent, withinFlowCollection) {
|
|
4306
|
+
let ch = this.peek();
|
|
4307
|
+
if (isWhiteSpaceOrEOL(ch) || isFlowIndicator(ch) || ch === SHARP || ch === AMPERSAND || ch === ASTERISK || ch === EXCLAMATION || ch === VERTICAL_LINE || ch === GREATER_THAN || ch === SINGLE_QUOTE || ch === DOUBLE_QUOTE || ch === PERCENT || ch === COMMERCIAL_AT || ch === GRAVE_ACCENT) {
|
|
4308
|
+
return;
|
|
4309
|
+
}
|
|
4310
|
+
let following;
|
|
4311
|
+
if (ch === QUESTION || ch === MINUS) {
|
|
4312
|
+
following = this.peek(1);
|
|
4313
|
+
if (isWhiteSpaceOrEOL(following) || withinFlowCollection && isFlowIndicator(following)) {
|
|
4314
|
+
return;
|
|
4315
|
+
}
|
|
4316
|
+
}
|
|
4317
|
+
let result = "";
|
|
4318
|
+
let captureEnd = this.position;
|
|
4319
|
+
let captureStart = this.position;
|
|
4320
|
+
let hasPendingContent = false;
|
|
4321
|
+
let line = 0;
|
|
4322
|
+
while (ch !== 0) {
|
|
4323
|
+
if (ch === COLON) {
|
|
4324
|
+
following = this.peek(1);
|
|
4325
|
+
if (isWhiteSpaceOrEOL(following) || withinFlowCollection && isFlowIndicator(following)) {
|
|
4326
|
+
break;
|
|
4327
|
+
}
|
|
4328
|
+
} else if (ch === SHARP) {
|
|
4329
|
+
const preceding = this.peek(-1);
|
|
4330
|
+
if (isWhiteSpaceOrEOL(preceding)) {
|
|
4331
|
+
break;
|
|
4332
|
+
}
|
|
4333
|
+
} else if (this.position === this.lineStart && this.testDocumentSeparator() || withinFlowCollection && isFlowIndicator(ch)) {
|
|
4334
|
+
break;
|
|
4335
|
+
} else if (isEOL(ch)) {
|
|
4336
|
+
line = this.line;
|
|
4337
|
+
const lineStart = this.lineStart;
|
|
4338
|
+
const lineIndent = this.lineIndent;
|
|
4339
|
+
this.skipSeparationSpace(false, -1);
|
|
4340
|
+
if (this.lineIndent >= nodeIndent) {
|
|
4341
|
+
hasPendingContent = true;
|
|
4342
|
+
ch = this.peek();
|
|
4343
|
+
continue;
|
|
4344
|
+
} else {
|
|
4345
|
+
this.position = captureEnd;
|
|
4346
|
+
this.line = line;
|
|
4347
|
+
this.lineStart = lineStart;
|
|
4348
|
+
this.lineIndent = lineIndent;
|
|
4349
|
+
break;
|
|
4350
|
+
}
|
|
4351
|
+
}
|
|
4352
|
+
if (hasPendingContent) {
|
|
4353
|
+
const segment2 = this.captureSegment(captureStart, captureEnd, false);
|
|
4354
|
+
if (segment2) result += segment2;
|
|
4355
|
+
result += writeFoldedLines(this.line - line);
|
|
4356
|
+
captureStart = captureEnd = this.position;
|
|
4357
|
+
hasPendingContent = false;
|
|
4358
|
+
}
|
|
4359
|
+
if (!isWhiteSpace(ch)) {
|
|
4360
|
+
captureEnd = this.position + 1;
|
|
4361
|
+
}
|
|
4362
|
+
ch = this.next();
|
|
4363
|
+
}
|
|
4364
|
+
const segment = this.captureSegment(captureStart, captureEnd, false);
|
|
4365
|
+
if (segment) result += segment;
|
|
4366
|
+
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
4367
|
+
if (result) return {
|
|
4368
|
+
tag,
|
|
4369
|
+
anchor,
|
|
4370
|
+
kind: "scalar",
|
|
4371
|
+
result
|
|
4372
|
+
};
|
|
4373
|
+
}
|
|
4374
|
+
readSingleQuotedScalar(tag, anchor, nodeIndent) {
|
|
4375
|
+
let ch = this.peek();
|
|
4376
|
+
if (ch !== SINGLE_QUOTE) return;
|
|
4377
|
+
let result = "";
|
|
4378
|
+
this.position++;
|
|
4379
|
+
let captureStart = this.position;
|
|
4380
|
+
let captureEnd = this.position;
|
|
4381
|
+
ch = this.peek();
|
|
4382
|
+
while (ch !== 0) {
|
|
4383
|
+
if (ch === SINGLE_QUOTE) {
|
|
4384
|
+
const segment = this.captureSegment(captureStart, this.position, true);
|
|
4385
|
+
if (segment) result += segment;
|
|
4386
|
+
ch = this.next();
|
|
4387
|
+
if (ch === SINGLE_QUOTE) {
|
|
4388
|
+
captureStart = this.position;
|
|
4389
|
+
this.position++;
|
|
4390
|
+
captureEnd = this.position;
|
|
4391
|
+
} else {
|
|
4392
|
+
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
4393
|
+
return {
|
|
4394
|
+
tag,
|
|
4395
|
+
anchor,
|
|
4396
|
+
kind: "scalar",
|
|
4397
|
+
result
|
|
4398
|
+
};
|
|
4399
|
+
}
|
|
4400
|
+
} else if (isEOL(ch)) {
|
|
4401
|
+
const segment = this.captureSegment(captureStart, captureEnd, true);
|
|
4402
|
+
if (segment) result += segment;
|
|
4403
|
+
result += writeFoldedLines(this.skipSeparationSpace(false, nodeIndent));
|
|
4404
|
+
captureStart = captureEnd = this.position;
|
|
4405
|
+
} else if (this.position === this.lineStart && this.testDocumentSeparator()) {
|
|
4406
|
+
throw this.#createError("Unexpected end of the document within a single quoted scalar");
|
|
4407
|
+
} else {
|
|
4408
|
+
this.position++;
|
|
4409
|
+
captureEnd = this.position;
|
|
4410
|
+
}
|
|
4411
|
+
ch = this.peek();
|
|
4412
|
+
}
|
|
4413
|
+
throw this.#createError("Unexpected end of the stream within a single quoted scalar");
|
|
4414
|
+
}
|
|
4415
|
+
readDoubleQuotedScalar(tag, anchor, nodeIndent) {
|
|
4416
|
+
let ch = this.peek();
|
|
4417
|
+
if (ch !== DOUBLE_QUOTE) return;
|
|
4418
|
+
let result = "";
|
|
4419
|
+
this.position++;
|
|
4420
|
+
let captureEnd = this.position;
|
|
4421
|
+
let captureStart = this.position;
|
|
4422
|
+
let tmp;
|
|
4423
|
+
ch = this.peek();
|
|
4424
|
+
while (ch !== 0) {
|
|
4425
|
+
if (ch === DOUBLE_QUOTE) {
|
|
4426
|
+
const segment = this.captureSegment(captureStart, this.position, true);
|
|
4427
|
+
if (segment) result += segment;
|
|
4428
|
+
this.position++;
|
|
4429
|
+
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
4430
|
+
return {
|
|
4431
|
+
tag,
|
|
4432
|
+
anchor,
|
|
4433
|
+
kind: "scalar",
|
|
4434
|
+
result
|
|
4435
|
+
};
|
|
4436
|
+
}
|
|
4437
|
+
if (ch === BACKSLASH) {
|
|
4438
|
+
const segment = this.captureSegment(captureStart, this.position, true);
|
|
4439
|
+
if (segment) result += segment;
|
|
4440
|
+
ch = this.next();
|
|
4441
|
+
if (isEOL(ch)) {
|
|
4442
|
+
this.skipSeparationSpace(false, nodeIndent);
|
|
4443
|
+
} else if (ch < 256 && SIMPLE_ESCAPE_SEQUENCES.has(ch)) {
|
|
4444
|
+
result += SIMPLE_ESCAPE_SEQUENCES.get(ch);
|
|
4445
|
+
this.position++;
|
|
4446
|
+
} else if ((tmp = ESCAPED_HEX_LENGTHS.get(ch) ?? 0) > 0) {
|
|
4447
|
+
let hexLength = tmp;
|
|
4448
|
+
let hexResult = 0;
|
|
4449
|
+
for (; hexLength > 0; hexLength--) {
|
|
4450
|
+
ch = this.next();
|
|
4451
|
+
if ((tmp = hexCharCodeToNumber(ch)) >= 0) {
|
|
4452
|
+
hexResult = (hexResult << 4) + tmp;
|
|
4453
|
+
} else {
|
|
4454
|
+
throw this.#createError("Cannot read double quoted scalar: expected hexadecimal character");
|
|
4455
|
+
}
|
|
4456
|
+
}
|
|
4457
|
+
result += codepointToChar(hexResult);
|
|
4458
|
+
this.position++;
|
|
4459
|
+
} else {
|
|
4460
|
+
throw this.#createError("Cannot read double quoted scalar: unknown escape sequence");
|
|
4461
|
+
}
|
|
4462
|
+
captureStart = captureEnd = this.position;
|
|
4463
|
+
} else if (isEOL(ch)) {
|
|
4464
|
+
const segment = this.captureSegment(captureStart, captureEnd, true);
|
|
4465
|
+
if (segment) result += segment;
|
|
4466
|
+
result += writeFoldedLines(this.skipSeparationSpace(false, nodeIndent));
|
|
4467
|
+
captureStart = captureEnd = this.position;
|
|
4468
|
+
} else if (this.position === this.lineStart && this.testDocumentSeparator()) {
|
|
4469
|
+
throw this.#createError("Unexpected end of the document within a double quoted scalar");
|
|
4470
|
+
} else {
|
|
4471
|
+
this.position++;
|
|
4472
|
+
captureEnd = this.position;
|
|
4473
|
+
}
|
|
4474
|
+
ch = this.peek();
|
|
4475
|
+
}
|
|
4476
|
+
throw this.#createError("Unexpected end of the stream within a double quoted scalar");
|
|
4477
|
+
}
|
|
4478
|
+
readFlowCollection(tag, anchor, nodeIndent) {
|
|
4479
|
+
let ch = this.peek();
|
|
4480
|
+
let terminator;
|
|
4481
|
+
let isMapping = true;
|
|
4482
|
+
let result = {};
|
|
4483
|
+
if (ch === LEFT_SQUARE_BRACKET) {
|
|
4484
|
+
terminator = RIGHT_SQUARE_BRACKET;
|
|
4485
|
+
isMapping = false;
|
|
4486
|
+
result = [];
|
|
4487
|
+
} else if (ch === LEFT_CURLY_BRACKET) {
|
|
4488
|
+
terminator = RIGHT_CURLY_BRACKET;
|
|
4489
|
+
} else {
|
|
4490
|
+
return;
|
|
4491
|
+
}
|
|
4492
|
+
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
4493
|
+
ch = this.next();
|
|
4494
|
+
let readNext = true;
|
|
4495
|
+
let valueNode = null;
|
|
4496
|
+
let keyNode = null;
|
|
4497
|
+
let keyTag = null;
|
|
4498
|
+
let isExplicitPair = false;
|
|
4499
|
+
let isPair = false;
|
|
4500
|
+
let following = 0;
|
|
4501
|
+
let line = 0;
|
|
4502
|
+
const overridableKeys = /* @__PURE__ */ new Set();
|
|
4503
|
+
while (ch !== 0) {
|
|
4504
|
+
this.skipSeparationSpace(true, nodeIndent);
|
|
4505
|
+
ch = this.peek();
|
|
4506
|
+
if (ch === terminator) {
|
|
4507
|
+
this.position++;
|
|
4508
|
+
const kind = isMapping ? "mapping" : "sequence";
|
|
4509
|
+
return {
|
|
4510
|
+
tag,
|
|
4511
|
+
anchor,
|
|
4512
|
+
kind,
|
|
4513
|
+
result
|
|
4514
|
+
};
|
|
4515
|
+
}
|
|
4516
|
+
if (!readNext) {
|
|
4517
|
+
throw this.#createError("Cannot read flow collection: missing comma between flow collection entries");
|
|
4518
|
+
}
|
|
4519
|
+
keyTag = keyNode = valueNode = null;
|
|
4520
|
+
isPair = isExplicitPair = false;
|
|
4521
|
+
if (ch === QUESTION) {
|
|
4522
|
+
following = this.peek(1);
|
|
4523
|
+
if (isWhiteSpaceOrEOL(following)) {
|
|
4524
|
+
isPair = isExplicitPair = true;
|
|
4525
|
+
this.position++;
|
|
4526
|
+
this.skipSeparationSpace(true, nodeIndent);
|
|
4527
|
+
}
|
|
4528
|
+
}
|
|
4529
|
+
line = this.line;
|
|
4530
|
+
const newState = this.composeNode({
|
|
4531
|
+
parentIndent: nodeIndent,
|
|
4532
|
+
nodeContext: CONTEXT_FLOW_IN,
|
|
4533
|
+
allowToSeek: false,
|
|
4534
|
+
allowCompact: true
|
|
4535
|
+
});
|
|
4536
|
+
if (newState) {
|
|
4537
|
+
keyTag = newState.tag || null;
|
|
4538
|
+
keyNode = newState.result;
|
|
4539
|
+
}
|
|
4540
|
+
this.skipSeparationSpace(true, nodeIndent);
|
|
4541
|
+
ch = this.peek();
|
|
4542
|
+
if ((isExplicitPair || this.line === line) && ch === COLON) {
|
|
4543
|
+
isPair = true;
|
|
4544
|
+
ch = this.next();
|
|
4545
|
+
this.skipSeparationSpace(true, nodeIndent);
|
|
4546
|
+
const newState2 = this.composeNode({
|
|
4547
|
+
parentIndent: nodeIndent,
|
|
4548
|
+
nodeContext: CONTEXT_FLOW_IN,
|
|
4549
|
+
allowToSeek: false,
|
|
4550
|
+
allowCompact: true
|
|
4551
|
+
});
|
|
4552
|
+
if (newState2) valueNode = newState2.result;
|
|
4553
|
+
}
|
|
4554
|
+
if (isMapping) {
|
|
4555
|
+
this.storeMappingPair(result, overridableKeys, keyTag, keyNode, valueNode);
|
|
4556
|
+
} else if (isPair) {
|
|
4557
|
+
result.push(this.storeMappingPair({}, overridableKeys, keyTag, keyNode, valueNode));
|
|
4558
|
+
} else {
|
|
4559
|
+
result.push(keyNode);
|
|
4560
|
+
}
|
|
4561
|
+
this.skipSeparationSpace(true, nodeIndent);
|
|
4562
|
+
ch = this.peek();
|
|
4563
|
+
if (ch === COMMA) {
|
|
4564
|
+
readNext = true;
|
|
4565
|
+
ch = this.next();
|
|
4566
|
+
} else {
|
|
4567
|
+
readNext = false;
|
|
4568
|
+
}
|
|
4569
|
+
}
|
|
4570
|
+
throw this.#createError("Cannot read flow collection: unexpected end of the stream within a flow collection");
|
|
4571
|
+
}
|
|
4572
|
+
// Handles block scaler styles: e.g. '|', '>', '|-' and '>-'.
|
|
4573
|
+
// https://yaml.org/spec/1.2.2/#81-block-scalar-styles
|
|
4574
|
+
readBlockScalar(tag, anchor, nodeIndent) {
|
|
4575
|
+
let chomping = CHOMPING_CLIP;
|
|
4576
|
+
let didReadContent = false;
|
|
4577
|
+
let detectedIndent = false;
|
|
4578
|
+
let textIndent = nodeIndent;
|
|
4579
|
+
let emptyLines = 0;
|
|
4580
|
+
let atMoreIndented = false;
|
|
4581
|
+
let ch = this.peek();
|
|
4582
|
+
let folding = false;
|
|
4583
|
+
if (ch === VERTICAL_LINE) {
|
|
4584
|
+
folding = false;
|
|
4585
|
+
} else if (ch === GREATER_THAN) {
|
|
4586
|
+
folding = true;
|
|
4587
|
+
} else {
|
|
4588
|
+
return;
|
|
4589
|
+
}
|
|
4590
|
+
let result = "";
|
|
4591
|
+
let tmp = 0;
|
|
4592
|
+
while (ch !== 0) {
|
|
4593
|
+
ch = this.next();
|
|
4594
|
+
if (ch === PLUS || ch === MINUS) {
|
|
4595
|
+
if (CHOMPING_CLIP === chomping) {
|
|
4596
|
+
chomping = ch === PLUS ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
4597
|
+
} else {
|
|
4598
|
+
throw this.#createError("Cannot read block: chomping mode identifier repeated");
|
|
4599
|
+
}
|
|
4600
|
+
} else if ((tmp = decimalCharCodeToNumber(ch)) >= 0) {
|
|
4601
|
+
if (tmp === 0) {
|
|
4602
|
+
throw this.#createError("Cannot read block: indentation width must be greater than 0");
|
|
4603
|
+
} else if (!detectedIndent) {
|
|
4604
|
+
textIndent = nodeIndent + tmp - 1;
|
|
4605
|
+
detectedIndent = true;
|
|
4606
|
+
} else {
|
|
4607
|
+
throw this.#createError("Cannot read block: indentation width identifier repeated");
|
|
4608
|
+
}
|
|
4609
|
+
} else {
|
|
4610
|
+
break;
|
|
4611
|
+
}
|
|
4612
|
+
}
|
|
4613
|
+
if (isWhiteSpace(ch)) {
|
|
4614
|
+
this.skipWhitespaces();
|
|
4615
|
+
this.skipComment();
|
|
4616
|
+
ch = this.peek();
|
|
4617
|
+
}
|
|
4618
|
+
while (ch !== 0) {
|
|
4619
|
+
this.readLineBreak();
|
|
4620
|
+
this.lineIndent = 0;
|
|
4621
|
+
ch = this.peek();
|
|
4622
|
+
while ((!detectedIndent || this.lineIndent < textIndent) && ch === SPACE) {
|
|
4623
|
+
this.lineIndent++;
|
|
4624
|
+
ch = this.next();
|
|
4625
|
+
}
|
|
4626
|
+
if (!detectedIndent && this.lineIndent > textIndent) {
|
|
4627
|
+
textIndent = this.lineIndent;
|
|
4628
|
+
}
|
|
4629
|
+
if (isEOL(ch)) {
|
|
4630
|
+
emptyLines++;
|
|
4631
|
+
continue;
|
|
4632
|
+
}
|
|
4633
|
+
if (this.lineIndent < textIndent) {
|
|
4634
|
+
if (chomping === CHOMPING_KEEP) {
|
|
4635
|
+
result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
|
|
4636
|
+
} else if (chomping === CHOMPING_CLIP) {
|
|
4637
|
+
if (didReadContent) {
|
|
4638
|
+
result += "\n";
|
|
4639
|
+
}
|
|
4640
|
+
}
|
|
4641
|
+
break;
|
|
4642
|
+
}
|
|
4643
|
+
if (folding) {
|
|
4644
|
+
if (isWhiteSpace(ch)) {
|
|
4645
|
+
atMoreIndented = true;
|
|
4646
|
+
result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
|
|
4647
|
+
} else if (atMoreIndented) {
|
|
4648
|
+
atMoreIndented = false;
|
|
4649
|
+
result += "\n".repeat(emptyLines + 1);
|
|
4650
|
+
} else if (emptyLines === 0) {
|
|
4651
|
+
if (didReadContent) {
|
|
4652
|
+
result += " ";
|
|
4653
|
+
}
|
|
4654
|
+
} else {
|
|
4655
|
+
result += "\n".repeat(emptyLines);
|
|
4656
|
+
}
|
|
4657
|
+
} else {
|
|
4658
|
+
result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
|
|
4659
|
+
}
|
|
4660
|
+
didReadContent = true;
|
|
4661
|
+
detectedIndent = true;
|
|
4662
|
+
emptyLines = 0;
|
|
4663
|
+
const captureStart = this.position;
|
|
4664
|
+
while (!isEOL(ch) && ch !== 0) {
|
|
4665
|
+
ch = this.next();
|
|
4666
|
+
}
|
|
4667
|
+
const segment = this.captureSegment(captureStart, this.position, false);
|
|
4668
|
+
if (segment) result += segment;
|
|
4669
|
+
}
|
|
4670
|
+
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
4671
|
+
return {
|
|
4672
|
+
tag,
|
|
4673
|
+
anchor,
|
|
4674
|
+
kind: "scalar",
|
|
4675
|
+
result
|
|
4676
|
+
};
|
|
4677
|
+
}
|
|
4678
|
+
readBlockMapping(tag, anchor, nodeIndent, flowIndent) {
|
|
4679
|
+
const result = {};
|
|
4680
|
+
const overridableKeys = /* @__PURE__ */ new Set();
|
|
4681
|
+
let allowCompact = false;
|
|
4682
|
+
let line;
|
|
4683
|
+
let pos;
|
|
4684
|
+
let keyTag = null;
|
|
4685
|
+
let keyNode = null;
|
|
4686
|
+
let valueNode = null;
|
|
4687
|
+
let atExplicitKey = false;
|
|
4688
|
+
let detected = false;
|
|
4689
|
+
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
4690
|
+
let ch = this.peek();
|
|
4691
|
+
while (ch !== 0) {
|
|
4692
|
+
const following = this.peek(1);
|
|
4693
|
+
line = this.line;
|
|
4694
|
+
pos = this.position;
|
|
4695
|
+
if ((ch === QUESTION || ch === COLON) && isWhiteSpaceOrEOL(following)) {
|
|
4696
|
+
if (ch === QUESTION) {
|
|
4697
|
+
if (atExplicitKey) {
|
|
4698
|
+
this.storeMappingPair(result, overridableKeys, keyTag, keyNode, null);
|
|
4699
|
+
keyTag = null;
|
|
4700
|
+
keyNode = null;
|
|
4701
|
+
valueNode = null;
|
|
4702
|
+
}
|
|
4703
|
+
detected = true;
|
|
4704
|
+
atExplicitKey = true;
|
|
4705
|
+
allowCompact = true;
|
|
4706
|
+
} else if (atExplicitKey) {
|
|
4707
|
+
atExplicitKey = false;
|
|
4708
|
+
allowCompact = true;
|
|
4709
|
+
} else {
|
|
4710
|
+
throw this.#createError("Cannot read block as explicit mapping pair is incomplete: a key node is missed or followed by a non-tabulated empty line");
|
|
4711
|
+
}
|
|
4712
|
+
this.position += 1;
|
|
4713
|
+
ch = following;
|
|
4714
|
+
} else {
|
|
4715
|
+
const newState = this.composeNode({
|
|
4716
|
+
parentIndent: flowIndent,
|
|
4717
|
+
nodeContext: CONTEXT_FLOW_OUT,
|
|
4718
|
+
allowToSeek: false,
|
|
4719
|
+
allowCompact: true
|
|
4720
|
+
});
|
|
4721
|
+
if (!newState) break;
|
|
4722
|
+
if (this.line === line) {
|
|
4723
|
+
ch = this.peek();
|
|
4724
|
+
this.skipWhitespaces();
|
|
4725
|
+
ch = this.peek();
|
|
4726
|
+
if (ch === COLON) {
|
|
4727
|
+
ch = this.next();
|
|
4728
|
+
if (!isWhiteSpaceOrEOL(ch)) {
|
|
4729
|
+
throw this.#createError("Cannot read block: a whitespace character is expected after the key-value separator within a block mapping");
|
|
2884
4730
|
}
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
type: "text",
|
|
2891
|
-
text: content
|
|
2892
|
-
}
|
|
2893
|
-
]
|
|
2894
|
-
};
|
|
2895
|
-
} catch {
|
|
2896
|
-
return {
|
|
2897
|
-
content: [
|
|
2898
|
-
{
|
|
2899
|
-
type: "text",
|
|
2900
|
-
text: `File not found: ${args.ref}`
|
|
2901
|
-
}
|
|
2902
|
-
],
|
|
2903
|
-
isError: true
|
|
2904
|
-
};
|
|
4731
|
+
if (atExplicitKey) {
|
|
4732
|
+
this.storeMappingPair(result, overridableKeys, keyTag, keyNode, null);
|
|
4733
|
+
keyTag = null;
|
|
4734
|
+
keyNode = null;
|
|
4735
|
+
valueNode = null;
|
|
2905
4736
|
}
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
}
|
|
2916
|
-
]
|
|
2917
|
-
};
|
|
2918
|
-
} catch {
|
|
4737
|
+
detected = true;
|
|
4738
|
+
atExplicitKey = false;
|
|
4739
|
+
allowCompact = false;
|
|
4740
|
+
keyTag = newState.tag;
|
|
4741
|
+
keyNode = newState.result;
|
|
4742
|
+
} else if (detected) {
|
|
4743
|
+
throw this.#createError("Cannot read an implicit mapping pair: missing colon");
|
|
4744
|
+
} else {
|
|
4745
|
+
const { kind, result: result2 } = newState;
|
|
2919
4746
|
return {
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
}
|
|
2925
|
-
],
|
|
2926
|
-
isError: true
|
|
4747
|
+
tag,
|
|
4748
|
+
anchor,
|
|
4749
|
+
kind,
|
|
4750
|
+
result: result2
|
|
2927
4751
|
};
|
|
2928
4752
|
}
|
|
2929
|
-
}
|
|
2930
|
-
|
|
4753
|
+
} else if (detected) {
|
|
4754
|
+
throw this.#createError("Cannot read a block mapping entry: a multiline key may not be an implicit key");
|
|
4755
|
+
} else {
|
|
4756
|
+
const { kind, result: result2 } = newState;
|
|
4757
|
+
return {
|
|
4758
|
+
tag,
|
|
4759
|
+
anchor,
|
|
4760
|
+
kind,
|
|
4761
|
+
result: result2
|
|
4762
|
+
};
|
|
4763
|
+
}
|
|
4764
|
+
}
|
|
4765
|
+
if (this.line === line || this.lineIndent > nodeIndent) {
|
|
4766
|
+
const newState = this.composeNode({
|
|
4767
|
+
parentIndent: nodeIndent,
|
|
4768
|
+
nodeContext: CONTEXT_BLOCK_OUT,
|
|
4769
|
+
allowToSeek: true,
|
|
4770
|
+
allowCompact
|
|
2931
4771
|
});
|
|
4772
|
+
if (newState) {
|
|
4773
|
+
if (atExplicitKey) {
|
|
4774
|
+
keyNode = newState.result;
|
|
4775
|
+
} else {
|
|
4776
|
+
valueNode = newState.result;
|
|
4777
|
+
}
|
|
4778
|
+
}
|
|
4779
|
+
if (!atExplicitKey) {
|
|
4780
|
+
this.storeMappingPair(result, overridableKeys, keyTag, keyNode, valueNode, line, pos);
|
|
4781
|
+
keyTag = keyNode = valueNode = null;
|
|
4782
|
+
}
|
|
4783
|
+
this.skipSeparationSpace(true, -1);
|
|
4784
|
+
ch = this.peek();
|
|
2932
4785
|
}
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
4786
|
+
if (this.lineIndent > nodeIndent && ch !== 0) {
|
|
4787
|
+
throw this.#createError("Cannot read block: bad indentation of a mapping entry");
|
|
4788
|
+
} else if (this.lineIndent < nodeIndent) {
|
|
4789
|
+
break;
|
|
4790
|
+
}
|
|
4791
|
+
}
|
|
4792
|
+
if (atExplicitKey) {
|
|
4793
|
+
this.storeMappingPair(result, overridableKeys, keyTag, keyNode, null);
|
|
4794
|
+
}
|
|
4795
|
+
if (detected) return {
|
|
4796
|
+
tag,
|
|
4797
|
+
anchor,
|
|
4798
|
+
kind: "mapping",
|
|
4799
|
+
result
|
|
4800
|
+
};
|
|
4801
|
+
}
|
|
4802
|
+
readTagProperty(tag) {
|
|
4803
|
+
let isVerbatim = false;
|
|
4804
|
+
let isNamed = false;
|
|
4805
|
+
let tagHandle = "";
|
|
4806
|
+
let tagName;
|
|
4807
|
+
let ch = this.peek();
|
|
4808
|
+
if (ch !== EXCLAMATION) return;
|
|
4809
|
+
if (tag !== null) {
|
|
4810
|
+
throw this.#createError("Cannot read tag property: duplication of a tag property");
|
|
4811
|
+
}
|
|
4812
|
+
ch = this.next();
|
|
4813
|
+
if (ch === SMALLER_THAN) {
|
|
4814
|
+
isVerbatim = true;
|
|
4815
|
+
ch = this.next();
|
|
4816
|
+
} else if (ch === EXCLAMATION) {
|
|
4817
|
+
isNamed = true;
|
|
4818
|
+
tagHandle = "!!";
|
|
4819
|
+
ch = this.next();
|
|
4820
|
+
} else {
|
|
4821
|
+
tagHandle = "!";
|
|
4822
|
+
}
|
|
4823
|
+
let position = this.position;
|
|
4824
|
+
if (isVerbatim) {
|
|
4825
|
+
do {
|
|
4826
|
+
ch = this.next();
|
|
4827
|
+
} while (ch !== 0 && ch !== GREATER_THAN);
|
|
4828
|
+
if (this.position < this.length) {
|
|
4829
|
+
tagName = this.input.slice(position, this.position);
|
|
4830
|
+
ch = this.next();
|
|
4831
|
+
} else {
|
|
4832
|
+
throw this.#createError("Cannot read tag property: unexpected end of stream");
|
|
4833
|
+
}
|
|
4834
|
+
} else {
|
|
4835
|
+
while (ch !== 0 && !isWhiteSpaceOrEOL(ch)) {
|
|
4836
|
+
if (ch === EXCLAMATION) {
|
|
4837
|
+
if (!isNamed) {
|
|
4838
|
+
tagHandle = this.input.slice(position - 1, this.position + 1);
|
|
4839
|
+
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
|
4840
|
+
throw this.#createError("Cannot read tag property: named tag handle contains invalid characters");
|
|
4841
|
+
}
|
|
4842
|
+
isNamed = true;
|
|
4843
|
+
position = this.position + 1;
|
|
4844
|
+
} else {
|
|
4845
|
+
throw this.#createError("Cannot read tag property: tag suffix cannot contain an exclamation mark");
|
|
4846
|
+
}
|
|
4847
|
+
}
|
|
4848
|
+
ch = this.next();
|
|
4849
|
+
}
|
|
4850
|
+
tagName = this.input.slice(position, this.position);
|
|
4851
|
+
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
|
4852
|
+
throw this.#createError("Cannot read tag property: tag suffix cannot contain flow indicator characters");
|
|
4853
|
+
}
|
|
4854
|
+
}
|
|
4855
|
+
if (tagName && !PATTERN_TAG_URI.test(tagName)) {
|
|
4856
|
+
throw this.#createError(`Cannot read tag property: invalid characters in tag name "${tagName}"`);
|
|
4857
|
+
}
|
|
4858
|
+
if (isVerbatim) {
|
|
4859
|
+
return tagName;
|
|
4860
|
+
} else if (this.tagMap.has(tagHandle)) {
|
|
4861
|
+
return this.tagMap.get(tagHandle) + tagName;
|
|
4862
|
+
} else if (tagHandle === "!") {
|
|
4863
|
+
return `!${tagName}`;
|
|
4864
|
+
} else if (tagHandle === "!!") {
|
|
4865
|
+
return `tag:yaml.org,2002:${tagName}`;
|
|
4866
|
+
}
|
|
4867
|
+
throw this.#createError(`Cannot read tag property: undeclared tag handle "${tagHandle}"`);
|
|
4868
|
+
}
|
|
4869
|
+
readAnchorProperty(anchor) {
|
|
4870
|
+
let ch = this.peek();
|
|
4871
|
+
if (ch !== AMPERSAND) return;
|
|
4872
|
+
if (anchor !== null) {
|
|
4873
|
+
throw this.#createError("Cannot read anchor property: duplicate anchor property");
|
|
4874
|
+
}
|
|
4875
|
+
ch = this.next();
|
|
4876
|
+
const position = this.position;
|
|
4877
|
+
while (ch !== 0 && !isWhiteSpaceOrEOL(ch) && !isFlowIndicator(ch)) {
|
|
4878
|
+
ch = this.next();
|
|
4879
|
+
}
|
|
4880
|
+
if (this.position === position) {
|
|
4881
|
+
throw this.#createError("Cannot read anchor property: name of an anchor node must contain at least one character");
|
|
4882
|
+
}
|
|
4883
|
+
return this.input.slice(position, this.position);
|
|
4884
|
+
}
|
|
4885
|
+
readAlias() {
|
|
4886
|
+
if (this.peek() !== ASTERISK) return;
|
|
4887
|
+
let ch = this.next();
|
|
4888
|
+
const position = this.position;
|
|
4889
|
+
while (ch !== 0 && !isWhiteSpaceOrEOL(ch) && !isFlowIndicator(ch)) {
|
|
4890
|
+
ch = this.next();
|
|
4891
|
+
}
|
|
4892
|
+
if (this.position === position) {
|
|
4893
|
+
throw this.#createError("Cannot read alias: alias name must contain at least one character");
|
|
4894
|
+
}
|
|
4895
|
+
const alias = this.input.slice(position, this.position);
|
|
4896
|
+
if (!this.anchorMap.has(alias)) {
|
|
4897
|
+
throw this.#createError(`Cannot read alias: unidentified alias "${alias}"`);
|
|
4898
|
+
}
|
|
4899
|
+
this.skipSeparationSpace(true, -1);
|
|
4900
|
+
return this.anchorMap.get(alias);
|
|
4901
|
+
}
|
|
4902
|
+
resolveTag(state) {
|
|
4903
|
+
switch (state.tag) {
|
|
4904
|
+
case null:
|
|
4905
|
+
case "!":
|
|
4906
|
+
return state;
|
|
4907
|
+
case "?": {
|
|
4908
|
+
for (const type2 of this.implicitTypes) {
|
|
4909
|
+
if (!type2.resolve(state.result)) continue;
|
|
4910
|
+
const result2 = type2.construct(state.result);
|
|
4911
|
+
state.result = result2;
|
|
4912
|
+
state.tag = type2.tag;
|
|
4913
|
+
const { anchor: anchor2 } = state;
|
|
4914
|
+
if (anchor2 !== null) this.anchorMap.set(anchor2, result2);
|
|
4915
|
+
return state;
|
|
4916
|
+
}
|
|
4917
|
+
return state;
|
|
4918
|
+
}
|
|
4919
|
+
}
|
|
4920
|
+
const kind = state.kind ?? "fallback";
|
|
4921
|
+
const map2 = this.typeMap[kind];
|
|
4922
|
+
const type = map2.get(state.tag);
|
|
4923
|
+
if (!type) {
|
|
4924
|
+
throw this.#createError(`Cannot resolve unknown tag !<${state.tag}>`);
|
|
4925
|
+
}
|
|
4926
|
+
if (state.result !== null && type.kind !== state.kind) {
|
|
4927
|
+
throw this.#createError(`Unacceptable node kind for !<${state.tag}> tag: it should be "${type.kind}", not "${state.kind}"`);
|
|
4928
|
+
}
|
|
4929
|
+
if (!type.resolve(state.result)) {
|
|
4930
|
+
throw this.#createError(`Cannot resolve a node with !<${state.tag}> explicit tag`);
|
|
4931
|
+
}
|
|
4932
|
+
const result = type.construct(state.result);
|
|
4933
|
+
state.result = result;
|
|
4934
|
+
const { anchor } = state;
|
|
4935
|
+
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
4936
|
+
return state;
|
|
4937
|
+
}
|
|
4938
|
+
composeNode({ parentIndent, nodeContext, allowToSeek, allowCompact }) {
|
|
4939
|
+
let indentStatus = 1;
|
|
4940
|
+
let atNewLine = false;
|
|
4941
|
+
const allowBlockScalars = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
|
|
4942
|
+
let allowBlockCollections = allowBlockScalars;
|
|
4943
|
+
const allowBlockStyles = allowBlockScalars;
|
|
4944
|
+
if (allowToSeek) {
|
|
4945
|
+
if (this.skipSeparationSpace(true, -1)) {
|
|
4946
|
+
atNewLine = true;
|
|
4947
|
+
indentStatus = getIndentStatus(this.lineIndent, parentIndent);
|
|
4948
|
+
}
|
|
4949
|
+
}
|
|
4950
|
+
let tag = null;
|
|
4951
|
+
let anchor = null;
|
|
4952
|
+
if (indentStatus === 1) {
|
|
4953
|
+
while (true) {
|
|
4954
|
+
const newTag = this.readTagProperty(tag);
|
|
4955
|
+
if (newTag) {
|
|
4956
|
+
tag = newTag;
|
|
4957
|
+
} else {
|
|
4958
|
+
const newAnchor = this.readAnchorProperty(anchor);
|
|
4959
|
+
if (!newAnchor) break;
|
|
4960
|
+
anchor = newAnchor;
|
|
4961
|
+
}
|
|
4962
|
+
if (this.skipSeparationSpace(true, -1)) {
|
|
4963
|
+
atNewLine = true;
|
|
4964
|
+
allowBlockCollections = allowBlockStyles;
|
|
4965
|
+
indentStatus = getIndentStatus(this.lineIndent, parentIndent);
|
|
4966
|
+
} else {
|
|
4967
|
+
allowBlockCollections = false;
|
|
4968
|
+
}
|
|
4969
|
+
}
|
|
4970
|
+
}
|
|
4971
|
+
if (allowBlockCollections) {
|
|
4972
|
+
allowBlockCollections = atNewLine || allowCompact;
|
|
4973
|
+
}
|
|
4974
|
+
if (indentStatus === 1) {
|
|
4975
|
+
const cond = CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext;
|
|
4976
|
+
const flowIndent = cond ? parentIndent : parentIndent + 1;
|
|
4977
|
+
if (allowBlockCollections) {
|
|
4978
|
+
const blockIndent = this.position - this.lineStart;
|
|
4979
|
+
const blockSequenceState = this.readBlockSequence(tag, anchor, blockIndent);
|
|
4980
|
+
if (blockSequenceState) return this.resolveTag(blockSequenceState);
|
|
4981
|
+
const blockMappingState = this.readBlockMapping(tag, anchor, blockIndent, flowIndent);
|
|
4982
|
+
if (blockMappingState) return this.resolveTag(blockMappingState);
|
|
4983
|
+
}
|
|
4984
|
+
const flowCollectionState = this.readFlowCollection(tag, anchor, flowIndent);
|
|
4985
|
+
if (flowCollectionState) return this.resolveTag(flowCollectionState);
|
|
4986
|
+
if (allowBlockScalars) {
|
|
4987
|
+
const blockScalarState = this.readBlockScalar(tag, anchor, flowIndent);
|
|
4988
|
+
if (blockScalarState) return this.resolveTag(blockScalarState);
|
|
4989
|
+
}
|
|
4990
|
+
const singleQuoteState = this.readSingleQuotedScalar(tag, anchor, flowIndent);
|
|
4991
|
+
if (singleQuoteState) return this.resolveTag(singleQuoteState);
|
|
4992
|
+
const doubleQuoteState = this.readDoubleQuotedScalar(tag, anchor, flowIndent);
|
|
4993
|
+
if (doubleQuoteState) return this.resolveTag(doubleQuoteState);
|
|
4994
|
+
const alias = this.readAlias();
|
|
4995
|
+
if (alias) {
|
|
4996
|
+
if (tag !== null || anchor !== null) {
|
|
4997
|
+
throw this.#createError("Cannot compose node: alias node should not have any properties");
|
|
4998
|
+
}
|
|
4999
|
+
return this.resolveTag({
|
|
5000
|
+
tag,
|
|
5001
|
+
anchor,
|
|
5002
|
+
kind: null,
|
|
5003
|
+
result: alias
|
|
5004
|
+
});
|
|
5005
|
+
}
|
|
5006
|
+
const plainScalarState = this.readPlainScalar(tag, anchor, flowIndent, CONTEXT_FLOW_IN === nodeContext);
|
|
5007
|
+
if (plainScalarState) {
|
|
5008
|
+
plainScalarState.tag ??= "?";
|
|
5009
|
+
return this.resolveTag(plainScalarState);
|
|
5010
|
+
}
|
|
5011
|
+
} else if (indentStatus === 0 && CONTEXT_BLOCK_OUT === nodeContext && allowBlockCollections) {
|
|
5012
|
+
const blockIndent = this.position - this.lineStart;
|
|
5013
|
+
const newState2 = this.readBlockSequence(tag, anchor, blockIndent);
|
|
5014
|
+
if (newState2) return this.resolveTag(newState2);
|
|
5015
|
+
}
|
|
5016
|
+
const newState = this.resolveTag({
|
|
5017
|
+
tag,
|
|
5018
|
+
anchor,
|
|
5019
|
+
kind: null,
|
|
5020
|
+
result: null
|
|
5021
|
+
});
|
|
5022
|
+
if (newState.tag !== null || newState.anchor !== null) return newState;
|
|
5023
|
+
}
|
|
5024
|
+
readDirectives() {
|
|
5025
|
+
let hasDirectives = false;
|
|
5026
|
+
let version = null;
|
|
5027
|
+
let ch = this.peek();
|
|
5028
|
+
while (ch !== 0) {
|
|
5029
|
+
this.skipSeparationSpace(true, -1);
|
|
5030
|
+
ch = this.peek();
|
|
5031
|
+
if (this.lineIndent > 0 || ch !== PERCENT) {
|
|
5032
|
+
break;
|
|
5033
|
+
}
|
|
5034
|
+
hasDirectives = true;
|
|
5035
|
+
ch = this.next();
|
|
5036
|
+
let position = this.position;
|
|
5037
|
+
while (ch !== 0 && !isWhiteSpaceOrEOL(ch)) {
|
|
5038
|
+
ch = this.next();
|
|
5039
|
+
}
|
|
5040
|
+
const directiveName = this.input.slice(position, this.position);
|
|
5041
|
+
const directiveArgs = [];
|
|
5042
|
+
if (directiveName.length < 1) {
|
|
5043
|
+
throw this.#createError("Cannot read document: directive name length must be greater than zero");
|
|
5044
|
+
}
|
|
5045
|
+
while (ch !== 0) {
|
|
5046
|
+
this.skipWhitespaces();
|
|
5047
|
+
this.skipComment();
|
|
5048
|
+
ch = this.peek();
|
|
5049
|
+
if (isEOL(ch)) break;
|
|
5050
|
+
position = this.position;
|
|
5051
|
+
while (ch !== 0 && !isWhiteSpaceOrEOL(ch)) {
|
|
5052
|
+
ch = this.next();
|
|
5053
|
+
}
|
|
5054
|
+
directiveArgs.push(this.input.slice(position, this.position));
|
|
5055
|
+
}
|
|
5056
|
+
if (ch !== 0) this.readLineBreak();
|
|
5057
|
+
switch (directiveName) {
|
|
5058
|
+
case "YAML":
|
|
5059
|
+
if (version !== null) {
|
|
5060
|
+
throw this.#createError("Cannot handle YAML directive: duplication of %YAML directive");
|
|
5061
|
+
}
|
|
5062
|
+
version = this.yamlDirectiveHandler(directiveArgs);
|
|
5063
|
+
break;
|
|
5064
|
+
case "TAG":
|
|
5065
|
+
this.tagDirectiveHandler(directiveArgs);
|
|
5066
|
+
break;
|
|
5067
|
+
default:
|
|
5068
|
+
this.dispatchWarning(`unknown document directive "${directiveName}"`);
|
|
5069
|
+
break;
|
|
5070
|
+
}
|
|
5071
|
+
ch = this.peek();
|
|
5072
|
+
}
|
|
5073
|
+
return hasDirectives;
|
|
5074
|
+
}
|
|
5075
|
+
readDocument() {
|
|
5076
|
+
const documentStart = this.position;
|
|
5077
|
+
this.checkLineBreaks = false;
|
|
5078
|
+
this.tagMap = /* @__PURE__ */ new Map();
|
|
5079
|
+
this.anchorMap = /* @__PURE__ */ new Map();
|
|
5080
|
+
const hasDirectives = this.readDirectives();
|
|
5081
|
+
this.skipSeparationSpace(true, -1);
|
|
5082
|
+
let result = null;
|
|
5083
|
+
if (this.lineIndent === 0 && this.peek() === MINUS && this.peek(1) === MINUS && this.peek(2) === MINUS) {
|
|
5084
|
+
this.position += 3;
|
|
5085
|
+
this.skipSeparationSpace(true, -1);
|
|
5086
|
+
} else if (hasDirectives) {
|
|
5087
|
+
throw this.#createError("Cannot read document: directives end mark is expected");
|
|
5088
|
+
}
|
|
5089
|
+
const newState = this.composeNode({
|
|
5090
|
+
parentIndent: this.lineIndent - 1,
|
|
5091
|
+
nodeContext: CONTEXT_BLOCK_OUT,
|
|
5092
|
+
allowToSeek: false,
|
|
5093
|
+
allowCompact: true
|
|
5094
|
+
});
|
|
5095
|
+
if (newState) result = newState.result;
|
|
5096
|
+
this.skipSeparationSpace(true, -1);
|
|
5097
|
+
if (this.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(this.input.slice(documentStart, this.position))) {
|
|
5098
|
+
this.dispatchWarning("non-ASCII line breaks are interpreted as content");
|
|
5099
|
+
}
|
|
5100
|
+
if (this.position === this.lineStart && this.testDocumentSeparator()) {
|
|
5101
|
+
if (this.peek() === DOT) {
|
|
5102
|
+
this.position += 3;
|
|
5103
|
+
this.skipSeparationSpace(true, -1);
|
|
5104
|
+
}
|
|
5105
|
+
} else if (this.position < this.length - 1) {
|
|
5106
|
+
throw this.#createError("Cannot read document: end of the stream or a document separator is expected");
|
|
5107
|
+
}
|
|
5108
|
+
return result;
|
|
5109
|
+
}
|
|
5110
|
+
*readDocuments() {
|
|
5111
|
+
while (this.position < this.length - 1) {
|
|
5112
|
+
yield this.readDocument();
|
|
5113
|
+
}
|
|
5114
|
+
}
|
|
5115
|
+
};
|
|
5116
|
+
|
|
5117
|
+
// __mcpc__cli_latest/node_modules/@jsr/std__yaml/parse.js
|
|
5118
|
+
function sanitizeInput(input) {
|
|
5119
|
+
input = String(input);
|
|
5120
|
+
if (input.length > 0) {
|
|
5121
|
+
if (!isEOL(input.charCodeAt(input.length - 1))) input += "\n";
|
|
5122
|
+
if (input.charCodeAt(0) === 65279) input = input.slice(1);
|
|
5123
|
+
}
|
|
5124
|
+
input += "\0";
|
|
5125
|
+
return input;
|
|
5126
|
+
}
|
|
5127
|
+
function parse(content, options = {}) {
|
|
5128
|
+
content = sanitizeInput(content);
|
|
5129
|
+
const state = new LoaderState(content, {
|
|
5130
|
+
...options,
|
|
5131
|
+
schema: SCHEMA_MAP.get(options.schema)
|
|
5132
|
+
});
|
|
5133
|
+
const documentGenerator = state.readDocuments();
|
|
5134
|
+
const document = documentGenerator.next().value;
|
|
5135
|
+
if (!documentGenerator.next().done) {
|
|
5136
|
+
throw new SyntaxError("Found more than 1 document in the stream: expected a single document");
|
|
5137
|
+
}
|
|
5138
|
+
return document ?? null;
|
|
5139
|
+
}
|
|
5140
|
+
|
|
5141
|
+
// __mcpc__cli_latest/node_modules/@jsr/mcpc__plugin-markdown-loader/src/markdown-loader.js
|
|
5142
|
+
var import_node_process2 = __toESM(require("node:process"), 1);
|
|
5143
|
+
function replaceEnvVars(str2) {
|
|
5144
|
+
return str2.replace(/\$([A-Za-z_][A-Za-z0-9_]*)(?!\s*\()/g, (match, varName) => {
|
|
5145
|
+
const value = import_node_process2.default.env[varName];
|
|
5146
|
+
if (value !== void 0) {
|
|
5147
|
+
return value;
|
|
5148
|
+
}
|
|
5149
|
+
return match;
|
|
5150
|
+
});
|
|
5151
|
+
}
|
|
5152
|
+
function replaceEnvVarsInObject(obj) {
|
|
5153
|
+
if (typeof obj === "string") {
|
|
5154
|
+
return replaceEnvVars(obj);
|
|
5155
|
+
}
|
|
5156
|
+
if (Array.isArray(obj)) {
|
|
5157
|
+
return obj.map((item) => replaceEnvVarsInObject(item));
|
|
5158
|
+
}
|
|
5159
|
+
if (obj && typeof obj === "object") {
|
|
5160
|
+
const result = {};
|
|
5161
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
5162
|
+
result[key] = replaceEnvVarsInObject(value);
|
|
5163
|
+
}
|
|
5164
|
+
return result;
|
|
5165
|
+
}
|
|
5166
|
+
return obj;
|
|
5167
|
+
}
|
|
5168
|
+
function parseMarkdownAgent(content) {
|
|
5169
|
+
const frontMatterRegex = /^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/;
|
|
5170
|
+
const match = content.match(frontMatterRegex);
|
|
5171
|
+
if (!match) {
|
|
5172
|
+
throw new Error("Invalid Markdown agent file: missing YAML front matter. Expected format:\n---\nname: agent-name\n---\n\n# Description...");
|
|
5173
|
+
}
|
|
5174
|
+
const [, yamlContent, markdownContent] = match;
|
|
5175
|
+
let frontMatter;
|
|
5176
|
+
try {
|
|
5177
|
+
frontMatter = parse(yamlContent);
|
|
5178
|
+
} catch (error) {
|
|
5179
|
+
throw new Error(`Failed to parse YAML front matter: ${error}`);
|
|
5180
|
+
}
|
|
5181
|
+
if (!frontMatter.name) {
|
|
5182
|
+
throw new Error("Invalid Markdown agent file: 'name' is required in front matter");
|
|
5183
|
+
}
|
|
5184
|
+
return {
|
|
5185
|
+
frontMatter,
|
|
5186
|
+
body: markdownContent.trim()
|
|
5187
|
+
};
|
|
5188
|
+
}
|
|
5189
|
+
var OPTION_KEYS = [
|
|
5190
|
+
"mode",
|
|
5191
|
+
"maxSteps",
|
|
5192
|
+
"maxTokens",
|
|
5193
|
+
"tracingEnabled",
|
|
5194
|
+
"refs",
|
|
5195
|
+
"samplingConfig",
|
|
5196
|
+
"providerOptions",
|
|
5197
|
+
"acpSettings"
|
|
5198
|
+
];
|
|
5199
|
+
function markdownAgentToComposeDefinition(parsed) {
|
|
5200
|
+
const frontMatter = replaceEnvVarsInObject(parsed.frontMatter);
|
|
5201
|
+
const body = replaceEnvVars(parsed.body);
|
|
5202
|
+
const options = {};
|
|
5203
|
+
for (const key of OPTION_KEYS) {
|
|
5204
|
+
if (frontMatter[key] !== void 0) {
|
|
5205
|
+
options[key] = frontMatter[key];
|
|
5206
|
+
}
|
|
5207
|
+
}
|
|
5208
|
+
const hasDescription = frontMatter.description !== void 0 && frontMatter.description !== "";
|
|
5209
|
+
return {
|
|
5210
|
+
name: frontMatter.name,
|
|
5211
|
+
description: hasDescription ? frontMatter.description : body,
|
|
5212
|
+
...hasDescription && body ? {
|
|
5213
|
+
manual: body
|
|
5214
|
+
} : {},
|
|
5215
|
+
deps: frontMatter.deps,
|
|
5216
|
+
plugins: frontMatter.plugins,
|
|
5217
|
+
...Object.keys(options).length > 0 ? {
|
|
5218
|
+
options
|
|
5219
|
+
} : {}
|
|
5220
|
+
};
|
|
5221
|
+
}
|
|
5222
|
+
async function loadMarkdownAgentFile(filePath) {
|
|
5223
|
+
const content = await (0, import_promises3.readFile)(filePath, "utf-8");
|
|
5224
|
+
const parsed = parseMarkdownAgent(content);
|
|
5225
|
+
return markdownAgentToComposeDefinition(parsed);
|
|
5226
|
+
}
|
|
5227
|
+
|
|
5228
|
+
// __mcpc__cli_latest/node_modules/@jsr/mcpc__plugin-markdown-loader/mod.js
|
|
5229
|
+
function markdownLoaderPlugin() {
|
|
5230
|
+
return {
|
|
5231
|
+
name: "markdown-loader",
|
|
5232
|
+
version: "1.0.0",
|
|
5233
|
+
enforce: "pre",
|
|
5234
|
+
configureServer: (server) => {
|
|
5235
|
+
server.registerFileLoader(".md", loadMarkdownAgentFile);
|
|
5236
|
+
server.registerFileLoader(".markdown", loadMarkdownAgentFile);
|
|
2937
5237
|
}
|
|
2938
5238
|
};
|
|
2939
5239
|
}
|
|
5240
|
+
var defaultPlugin = markdownLoaderPlugin();
|
|
2940
5241
|
|
|
2941
5242
|
// __mcpc__cli_latest/node_modules/@mcpc/cli/src/defaults.js
|
|
2942
|
-
var import_plugin_code_execution = require("@mcpc-tech/plugin-code-execution");
|
|
2943
|
-
var import_plugin_markdown_loader = require("@mcpc-tech/plugin-markdown-loader");
|
|
2944
5243
|
var import_node_path5 = require("node:path");
|
|
2945
|
-
var
|
|
5244
|
+
var import_node_process3 = __toESM(require("node:process"), 1);
|
|
2946
5245
|
var DEFAULT_SKILLS_PATHS = [
|
|
2947
5246
|
".claude/skills"
|
|
2948
5247
|
];
|
|
2949
5248
|
var DEFAULT_CODE_EXECUTION_TIMEOUT = 3e5;
|
|
2950
5249
|
function getGlobalPlugins(skillsPaths) {
|
|
2951
|
-
const resolvedPaths = skillsPaths.map((p2) => (0, import_node_path5.resolve)(
|
|
5250
|
+
const resolvedPaths = skillsPaths.map((p2) => (0, import_node_path5.resolve)(import_node_process3.default.cwd(), p2));
|
|
2952
5251
|
return [
|
|
2953
|
-
|
|
5252
|
+
markdownLoaderPlugin(),
|
|
2954
5253
|
createSkillsPlugin({
|
|
2955
5254
|
paths: resolvedPaths
|
|
2956
5255
|
})
|
|
@@ -2982,6 +5281,7 @@ function getDefaultAgents() {
|
|
|
2982
5281
|
}
|
|
2983
5282
|
|
|
2984
5283
|
// __mcpc__cli_latest/node_modules/@mcpc/cli/src/config/loader.js
|
|
5284
|
+
var CLI_VERSION = "0.1.44";
|
|
2985
5285
|
function extractServerName(command, commandArgs) {
|
|
2986
5286
|
for (const arg of commandArgs) {
|
|
2987
5287
|
if (!arg.startsWith("-")) {
|
|
@@ -3004,7 +5304,7 @@ async function saveUserConfig(config, newAgentName) {
|
|
|
3004
5304
|
try {
|
|
3005
5305
|
let existingConfig = null;
|
|
3006
5306
|
try {
|
|
3007
|
-
const content = await (0,
|
|
5307
|
+
const content = await (0, import_promises4.readFile)(configPath, "utf-8");
|
|
3008
5308
|
existingConfig = JSON.parse(content);
|
|
3009
5309
|
} catch {
|
|
3010
5310
|
}
|
|
@@ -3018,7 +5318,7 @@ async function saveUserConfig(config, newAgentName) {
|
|
|
3018
5318
|
return;
|
|
3019
5319
|
}
|
|
3020
5320
|
existingConfig.agents.push(...config.agents);
|
|
3021
|
-
await (0,
|
|
5321
|
+
await (0, import_promises4.writeFile)(configPath, JSON.stringify(existingConfig, null, 2), "utf-8");
|
|
3022
5322
|
console.error(`
|
|
3023
5323
|
\u2713 Added agent "${newAgentName}" (total: ${existingConfig.agents.length})
|
|
3024
5324
|
Config: ${configPath}
|
|
@@ -3026,10 +5326,10 @@ async function saveUserConfig(config, newAgentName) {
|
|
|
3026
5326
|
`);
|
|
3027
5327
|
return;
|
|
3028
5328
|
}
|
|
3029
|
-
await (0,
|
|
5329
|
+
await (0, import_promises4.mkdir)(configDir, {
|
|
3030
5330
|
recursive: true
|
|
3031
5331
|
});
|
|
3032
|
-
await (0,
|
|
5332
|
+
await (0, import_promises4.writeFile)(configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
3033
5333
|
console.error(`
|
|
3034
5334
|
\u2713 Configuration saved to: ${configPath}
|
|
3035
5335
|
Run: mcpc
|
|
@@ -3041,7 +5341,7 @@ async function saveUserConfig(config, newAgentName) {
|
|
|
3041
5341
|
async function createWrapConfig(args) {
|
|
3042
5342
|
if (!args.mcpServers || args.mcpServers.length === 0) {
|
|
3043
5343
|
console.error("Error: --wrap/--add requires at least one MCP server\nExample: mcpc --wrap --mcp-stdio 'npx -y @wonderwhy-er/desktop-commander'\nMultiple: mcpc --add --mcp-stdio 'npx -y server1' --mcp-http 'https://api.example.com'");
|
|
3044
|
-
|
|
5344
|
+
import_node_process4.default.exit(1);
|
|
3045
5345
|
}
|
|
3046
5346
|
const mcpServers = {};
|
|
3047
5347
|
const serverNames = [];
|
|
@@ -3089,97 +5389,50 @@ Created configuration for ${serverNames.length} MCP server(s)${modeInfo}`);
|
|
|
3089
5389
|
}
|
|
3090
5390
|
return config;
|
|
3091
5391
|
}
|
|
5392
|
+
function printVersion() {
|
|
5393
|
+
console.log(`mcpc ${CLI_VERSION}`);
|
|
5394
|
+
}
|
|
3092
5395
|
function printHelp() {
|
|
3093
5396
|
console.log(`
|
|
3094
|
-
|
|
5397
|
+
mcpc ${CLI_VERSION} - Model Context Protocol Composer
|
|
3095
5398
|
|
|
3096
5399
|
USAGE:
|
|
3097
5400
|
mcpc [OPTIONS]
|
|
3098
5401
|
|
|
3099
5402
|
OPTIONS:
|
|
3100
|
-
--help
|
|
5403
|
+
-h, --help Show this help message
|
|
5404
|
+
-v, --version Show version information
|
|
3101
5405
|
--cwd <path> Change working directory before loading config
|
|
3102
|
-
Useful when running from MCP Inspector or other tools
|
|
3103
5406
|
--config <json> Inline JSON configuration string
|
|
3104
5407
|
--config-url <url> Fetch configuration from URL
|
|
3105
5408
|
--config-file <path> Load configuration from file path
|
|
3106
|
-
--skills <dirs> Skills directories (comma-separated)
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
--mode <mode> Set execution mode for JSON/object agents (does not
|
|
3113
|
-
affect Markdown agent files which define mode in frontmatter)
|
|
3114
|
-
Supported modes:
|
|
3115
|
-
- agentic: Fully autonomous agent mode (default)
|
|
3116
|
-
- ai_sampling: AI SDK sampling mode for autonomous execution
|
|
3117
|
-
- ai_acp: AI SDK ACP mode for coding agents
|
|
3118
|
-
- code_execution: Code execution mode (requires @mcpc-tech/plugin-code-execution)
|
|
5409
|
+
--skills <dirs> Skills directories (comma-separated)
|
|
5410
|
+
-H, --request-headers <header>
|
|
5411
|
+
Add custom HTTP header for URL fetching
|
|
5412
|
+
Format: "Key: Value" or "Key=Value"
|
|
5413
|
+
--mode <mode> Set execution mode for agents
|
|
5414
|
+
Modes: agentic, ai_sampling, ai_acp, code_execution
|
|
3119
5415
|
--add Add MCP servers to ~/.mcpc/config.json and exit
|
|
3120
|
-
|
|
3121
|
-
Use --mcp-stdio, --mcp-http, or --mcp-sse to specify servers
|
|
3122
|
-
--wrap Wrap and run MCP servers immediately without saving config
|
|
3123
|
-
Use --mcp-stdio, --mcp-http, or --mcp-sse to specify servers
|
|
5416
|
+
--wrap Wrap and run MCP servers immediately
|
|
3124
5417
|
--mcp-stdio <cmd> Add an MCP server with stdio transport
|
|
3125
|
-
Example: --mcp-stdio "npx -y @wonderwhy-er/desktop-commander"
|
|
3126
5418
|
--mcp-http <url> Add an MCP server with streamable-http transport
|
|
3127
|
-
Example: --mcp-http "https://api.github.com/mcp"
|
|
3128
5419
|
--mcp-sse <url> Add an MCP server with SSE transport
|
|
3129
|
-
|
|
3130
|
-
--name <name> Custom agent name for wrap mode (overrides auto-detection)
|
|
5420
|
+
--name <name> Custom agent name for wrap mode
|
|
3131
5421
|
|
|
3132
5422
|
ENVIRONMENT VARIABLES:
|
|
3133
|
-
MCPC_CONFIG
|
|
3134
|
-
MCPC_CONFIG_URL
|
|
3135
|
-
MCPC_CONFIG_FILE
|
|
5423
|
+
MCPC_CONFIG Inline JSON configuration
|
|
5424
|
+
MCPC_CONFIG_URL URL to fetch config from
|
|
5425
|
+
MCPC_CONFIG_FILE Path to config file
|
|
3136
5426
|
|
|
3137
5427
|
EXAMPLES:
|
|
3138
|
-
# Show help
|
|
3139
5428
|
mcpc --help
|
|
3140
|
-
|
|
3141
|
-
# Add MCP servers to config and save to ~/.mcpc/config.json
|
|
5429
|
+
mcpc --version
|
|
3142
5430
|
mcpc --add --mcp-stdio "npx -y @wonderwhy-er/desktop-commander"
|
|
3143
|
-
# Edit ~/.mcpc/config.json if needed (add headers, etc.)
|
|
3144
|
-
mcpc # Loads config from ~/.mcpc/config.json automatically
|
|
3145
|
-
|
|
3146
|
-
# Wrap and run immediately (one-time use, no config saved)
|
|
3147
5431
|
mcpc --wrap --mcp-stdio "npx -y @wonderwhy-er/desktop-commander"
|
|
3148
|
-
|
|
3149
|
-
# Multiple servers with different transports
|
|
3150
|
-
mcpc --add --mcp-stdio "npx -y @wonderwhy-er/desktop-commander" --mcp-http "https://api.github.com/mcp" --mcp-sse "https://api.example.com/sse"
|
|
3151
|
-
|
|
3152
|
-
# Custom agent name
|
|
3153
|
-
mcpc --add --name my-agent --mcp-stdio "npx shadcn@latest mcp"
|
|
3154
|
-
mcpc --wrap --name my-agent --mcp-stdio "npx shadcn@latest mcp"
|
|
3155
|
-
|
|
3156
|
-
# Load from URL
|
|
3157
|
-
mcpc --config-url \\
|
|
3158
|
-
"https://raw.githubusercontent.com/mcpc-tech/mcpc/main/packages/cli/examples/configs/codex-fork.json"
|
|
3159
|
-
|
|
3160
|
-
# Load from URL with custom headers
|
|
3161
|
-
mcpc \\
|
|
3162
|
-
--config-url "https://api.example.com/config.json" \\
|
|
3163
|
-
-H "Authorization: Bearer token123" \\
|
|
3164
|
-
-H "X-Custom-Header: value"
|
|
3165
|
-
|
|
3166
|
-
# Load from file
|
|
5432
|
+
mcpc --config-url "https://example.com/config.json"
|
|
3167
5433
|
mcpc --config-file ./my-config.json
|
|
3168
5434
|
|
|
3169
|
-
|
|
3170
|
-
mcpc --config-file ./my-config.json --mode ai_sampling
|
|
3171
|
-
|
|
3172
|
-
# Using environment variable
|
|
3173
|
-
export MCPC_CONFIG='[{"name":"agent","description":"..."}]'
|
|
3174
|
-
mcpc
|
|
3175
|
-
|
|
3176
|
-
# Use default configuration (./mcpc.config.json)
|
|
3177
|
-
mcpc
|
|
3178
|
-
|
|
3179
|
-
CONFIGURATION:
|
|
3180
|
-
Configuration files support environment variable substitution using $VAR_NAME syntax.
|
|
3181
|
-
|
|
3182
|
-
Priority order:
|
|
5435
|
+
CONFIG PRIORITY:
|
|
3183
5436
|
1. --config (inline JSON)
|
|
3184
5437
|
2. MCPC_CONFIG environment variable
|
|
3185
5438
|
3. --config-url or MCPC_CONFIG_URL
|
|
@@ -3187,93 +5440,140 @@ CONFIGURATION:
|
|
|
3187
5440
|
5. ~/.mcpc/config.json (user config)
|
|
3188
5441
|
6. ./mcpc.config.json (local config)
|
|
3189
5442
|
|
|
3190
|
-
For more information
|
|
5443
|
+
For more information: https://github.com/mcpc-tech/mcpc
|
|
3191
5444
|
`);
|
|
3192
5445
|
}
|
|
3193
|
-
function
|
|
3194
|
-
const
|
|
3195
|
-
const
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
5446
|
+
function parseHeader(headerStr) {
|
|
5447
|
+
const colonIdx = headerStr.indexOf(":");
|
|
5448
|
+
const equalIdx = headerStr.indexOf("=");
|
|
5449
|
+
const separatorIdx = colonIdx !== -1 ? equalIdx !== -1 ? Math.min(colonIdx, equalIdx) : colonIdx : equalIdx;
|
|
5450
|
+
if (separatorIdx !== -1) {
|
|
5451
|
+
return {
|
|
5452
|
+
key: headerStr.substring(0, separatorIdx).trim(),
|
|
5453
|
+
value: headerStr.substring(separatorIdx + 1).trim()
|
|
5454
|
+
};
|
|
5455
|
+
}
|
|
5456
|
+
return null;
|
|
5457
|
+
}
|
|
5458
|
+
function parseMcpServer(cmdString, transportType) {
|
|
5459
|
+
const cmdParts = cmdString.split(/\s+/);
|
|
5460
|
+
return {
|
|
5461
|
+
command: cmdParts[0],
|
|
5462
|
+
args: cmdParts.slice(1),
|
|
5463
|
+
transportType
|
|
5464
|
+
};
|
|
5465
|
+
}
|
|
5466
|
+
function parseCLIArgs() {
|
|
5467
|
+
const args = parseArgs(import_node_process4.default.argv.slice(2), {
|
|
5468
|
+
boolean: [
|
|
5469
|
+
"help",
|
|
5470
|
+
"version",
|
|
5471
|
+
"add",
|
|
5472
|
+
"wrap"
|
|
5473
|
+
],
|
|
5474
|
+
string: [
|
|
5475
|
+
"cwd",
|
|
5476
|
+
"config",
|
|
5477
|
+
"config-url",
|
|
5478
|
+
"config-file",
|
|
5479
|
+
"mode",
|
|
5480
|
+
"name",
|
|
5481
|
+
"skills",
|
|
5482
|
+
"mcp-stdio",
|
|
5483
|
+
"mcp-http",
|
|
5484
|
+
"mcp-sse"
|
|
5485
|
+
],
|
|
5486
|
+
collect: [
|
|
5487
|
+
"request-headers",
|
|
5488
|
+
"mcp-stdio",
|
|
5489
|
+
"mcp-http",
|
|
5490
|
+
"mcp-sse"
|
|
5491
|
+
],
|
|
5492
|
+
alias: {
|
|
5493
|
+
h: "help",
|
|
5494
|
+
v: "version",
|
|
5495
|
+
H: "request-headers"
|
|
5496
|
+
},
|
|
5497
|
+
default: {
|
|
5498
|
+
help: false,
|
|
5499
|
+
version: false,
|
|
5500
|
+
add: false,
|
|
5501
|
+
wrap: false
|
|
5502
|
+
}
|
|
5503
|
+
});
|
|
5504
|
+
const result = {
|
|
5505
|
+
help: args.help,
|
|
5506
|
+
version: args.version,
|
|
5507
|
+
add: args.add,
|
|
5508
|
+
wrap: args.wrap,
|
|
5509
|
+
cwd: args.cwd,
|
|
5510
|
+
config: args.config,
|
|
5511
|
+
configUrl: args["config-url"],
|
|
5512
|
+
configFile: args["config-file"],
|
|
5513
|
+
mode: args.mode,
|
|
5514
|
+
name: args.name
|
|
5515
|
+
};
|
|
5516
|
+
if (args.skills) {
|
|
5517
|
+
result.skills = args.skills.split(",").map((s) => s.trim()).filter(Boolean);
|
|
5518
|
+
}
|
|
5519
|
+
const headers = args["request-headers"];
|
|
5520
|
+
if (headers && headers.length > 0) {
|
|
5521
|
+
result.requestHeaders = {};
|
|
5522
|
+
for (const h of headers) {
|
|
5523
|
+
const parsed = parseHeader(h);
|
|
5524
|
+
if (parsed) {
|
|
5525
|
+
result.requestHeaders[parsed.key] = parsed.value;
|
|
5526
|
+
}
|
|
5527
|
+
}
|
|
5528
|
+
}
|
|
5529
|
+
const mcpStdio = args["mcp-stdio"];
|
|
5530
|
+
const mcpHttp = args["mcp-http"];
|
|
5531
|
+
const mcpSse = args["mcp-sse"];
|
|
5532
|
+
if (mcpStdio && mcpStdio.length > 0 || mcpHttp && mcpHttp.length > 0 || mcpSse && mcpSse.length > 0) {
|
|
5533
|
+
result.mcpServers = [];
|
|
5534
|
+
if (mcpStdio) {
|
|
5535
|
+
for (const cmd of mcpStdio) {
|
|
5536
|
+
result.mcpServers.push(parseMcpServer(cmd, "stdio"));
|
|
3237
5537
|
}
|
|
3238
|
-
|
|
3239
|
-
|
|
5538
|
+
}
|
|
5539
|
+
if (mcpHttp) {
|
|
5540
|
+
for (const url2 of mcpHttp) {
|
|
5541
|
+
result.mcpServers.push(parseMcpServer(url2, "streamable-http"));
|
|
5542
|
+
}
|
|
5543
|
+
}
|
|
5544
|
+
if (mcpSse) {
|
|
5545
|
+
for (const url2 of mcpSse) {
|
|
5546
|
+
result.mcpServers.push(parseMcpServer(url2, "sse"));
|
|
3240
5547
|
}
|
|
3241
|
-
result.mcpServers.push({
|
|
3242
|
-
command,
|
|
3243
|
-
args: cmdArgs,
|
|
3244
|
-
transportType
|
|
3245
|
-
});
|
|
3246
|
-
} else if (arg === "--mode" && i + 1 < args.length) {
|
|
3247
|
-
result.mode = args[++i];
|
|
3248
|
-
} else if (arg === "--name" && i + 1 < args.length) {
|
|
3249
|
-
result.name = args[++i];
|
|
3250
|
-
} else if (arg === "--skills" && i + 1 < args.length) {
|
|
3251
|
-
result.skills = args[++i].split(",").map((s) => s.trim()).filter(Boolean);
|
|
3252
5548
|
}
|
|
3253
5549
|
}
|
|
3254
5550
|
return result;
|
|
3255
5551
|
}
|
|
3256
5552
|
async function loadConfig() {
|
|
3257
|
-
const args =
|
|
5553
|
+
const args = parseCLIArgs();
|
|
5554
|
+
if (args.version) {
|
|
5555
|
+
printVersion();
|
|
5556
|
+
import_node_process4.default.exit(0);
|
|
5557
|
+
}
|
|
5558
|
+
if (args.help) {
|
|
5559
|
+
printHelp();
|
|
5560
|
+
import_node_process4.default.exit(0);
|
|
5561
|
+
}
|
|
3258
5562
|
if (args.cwd) {
|
|
3259
|
-
const targetCwd = (0, import_node_path6.resolve)(
|
|
3260
|
-
|
|
5563
|
+
const targetCwd = (0, import_node_path6.resolve)(import_node_process4.default.cwd(), args.cwd);
|
|
5564
|
+
import_node_process4.default.chdir(targetCwd);
|
|
3261
5565
|
console.error(`Changed working directory to: ${targetCwd}`);
|
|
3262
5566
|
}
|
|
3263
5567
|
const mergeSkills = (config) => {
|
|
3264
5568
|
config.skills = args.skills || config.skills || DEFAULT_SKILLS_PATHS;
|
|
3265
5569
|
return config;
|
|
3266
5570
|
};
|
|
3267
|
-
if (args.help) {
|
|
3268
|
-
printHelp();
|
|
3269
|
-
import_node_process3.default.exit(0);
|
|
3270
|
-
}
|
|
3271
5571
|
if (args.add) {
|
|
3272
5572
|
await createWrapConfig({
|
|
3273
5573
|
...args,
|
|
3274
5574
|
saveConfig: true
|
|
3275
5575
|
});
|
|
3276
|
-
|
|
5576
|
+
import_node_process4.default.exit(0);
|
|
3277
5577
|
}
|
|
3278
5578
|
if (args.wrap) {
|
|
3279
5579
|
return mergeSkills(await createWrapConfig({
|
|
@@ -3290,16 +5590,16 @@ async function loadConfig() {
|
|
|
3290
5590
|
throw error;
|
|
3291
5591
|
}
|
|
3292
5592
|
}
|
|
3293
|
-
if (
|
|
5593
|
+
if (import_node_process4.default.env.MCPC_CONFIG) {
|
|
3294
5594
|
try {
|
|
3295
|
-
const parsed = JSON.parse(
|
|
5595
|
+
const parsed = JSON.parse(import_node_process4.default.env.MCPC_CONFIG);
|
|
3296
5596
|
return mergeSkills(applyModeOverride(normalizeConfig(parsed), args.mode));
|
|
3297
5597
|
} catch (error) {
|
|
3298
5598
|
console.error("Failed to parse MCPC_CONFIG environment variable:", error);
|
|
3299
5599
|
throw error;
|
|
3300
5600
|
}
|
|
3301
5601
|
}
|
|
3302
|
-
const configUrl = args.configUrl ||
|
|
5602
|
+
const configUrl = args.configUrl || import_node_process4.default.env.MCPC_CONFIG_URL;
|
|
3303
5603
|
if (configUrl) {
|
|
3304
5604
|
try {
|
|
3305
5605
|
const headers = {
|
|
@@ -3320,7 +5620,7 @@ async function loadConfig() {
|
|
|
3320
5620
|
throw error;
|
|
3321
5621
|
}
|
|
3322
5622
|
}
|
|
3323
|
-
const configFile = args.configFile ||
|
|
5623
|
+
const configFile = args.configFile || import_node_process4.default.env.MCPC_CONFIG_FILE;
|
|
3324
5624
|
if (configFile) {
|
|
3325
5625
|
try {
|
|
3326
5626
|
const config = await loadConfigFromFile(configFile);
|
|
@@ -3345,7 +5645,7 @@ async function loadConfig() {
|
|
|
3345
5645
|
throw error;
|
|
3346
5646
|
}
|
|
3347
5647
|
}
|
|
3348
|
-
const defaultJsonConfigPath = (0, import_node_path6.resolve)(
|
|
5648
|
+
const defaultJsonConfigPath = (0, import_node_path6.resolve)(import_node_process4.default.cwd(), "mcpc.config.json");
|
|
3349
5649
|
try {
|
|
3350
5650
|
const config = await loadConfigFromFile(defaultJsonConfigPath);
|
|
3351
5651
|
return mergeSkills(applyModeOverride(config, args.mode));
|
|
@@ -3358,16 +5658,16 @@ async function loadConfig() {
|
|
|
3358
5658
|
}
|
|
3359
5659
|
}
|
|
3360
5660
|
}
|
|
3361
|
-
function
|
|
3362
|
-
return
|
|
3363
|
-
return
|
|
5661
|
+
function replaceEnvVars2(str2) {
|
|
5662
|
+
return str2.replace(/\$([A-Z_][A-Z0-9_]*)/g, (_match, varName) => {
|
|
5663
|
+
return import_node_process4.default.env[varName] || "";
|
|
3364
5664
|
});
|
|
3365
5665
|
}
|
|
3366
|
-
function
|
|
5666
|
+
function isMarkdownFile2(path) {
|
|
3367
5667
|
return path.endsWith(".md") || path.endsWith(".markdown");
|
|
3368
5668
|
}
|
|
3369
5669
|
async function loadConfigFromFile(filePath) {
|
|
3370
|
-
if (
|
|
5670
|
+
if (isMarkdownFile2(filePath)) {
|
|
3371
5671
|
return {
|
|
3372
5672
|
name: "mcpc-server",
|
|
3373
5673
|
version: "0.1.0",
|
|
@@ -3376,13 +5676,13 @@ async function loadConfigFromFile(filePath) {
|
|
|
3376
5676
|
]
|
|
3377
5677
|
};
|
|
3378
5678
|
}
|
|
3379
|
-
const content = await (0,
|
|
5679
|
+
const content = await (0, import_promises4.readFile)(filePath, "utf-8");
|
|
3380
5680
|
const parsed = JSON.parse(content);
|
|
3381
5681
|
return normalizeConfig(parsed);
|
|
3382
5682
|
}
|
|
3383
5683
|
function replaceEnvVarsInConfig(obj) {
|
|
3384
5684
|
if (typeof obj === "string") {
|
|
3385
|
-
return
|
|
5685
|
+
return replaceEnvVars2(obj);
|
|
3386
5686
|
}
|
|
3387
5687
|
if (Array.isArray(obj)) {
|
|
3388
5688
|
return obj.map((item) => replaceEnvVarsInConfig(item));
|
|
@@ -4468,7 +6768,7 @@ var Protocol = class {
|
|
|
4468
6768
|
};
|
|
4469
6769
|
}
|
|
4470
6770
|
};
|
|
4471
|
-
function
|
|
6771
|
+
function isPlainObject2(value) {
|
|
4472
6772
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
4473
6773
|
}
|
|
4474
6774
|
function mergeCapabilities(base, additional) {
|
|
@@ -4479,7 +6779,7 @@ function mergeCapabilities(base, additional) {
|
|
|
4479
6779
|
if (addValue === void 0)
|
|
4480
6780
|
continue;
|
|
4481
6781
|
const baseValue = result[k];
|
|
4482
|
-
if (
|
|
6782
|
+
if (isPlainObject2(baseValue) && isPlainObject2(addValue)) {
|
|
4483
6783
|
result[k] = { ...baseValue, ...addValue };
|
|
4484
6784
|
} else {
|
|
4485
6785
|
result[k] = addValue;
|
|
@@ -5777,9 +8077,9 @@ var Client = class extends Protocol {
|
|
|
5777
8077
|
|
|
5778
8078
|
// __mcpc__cli_latest/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
|
|
5779
8079
|
var import_cross_spawn = __toESM(require_cross_spawn(), 1);
|
|
5780
|
-
var
|
|
8080
|
+
var import_node_process5 = __toESM(require("node:process"), 1);
|
|
5781
8081
|
var import_node_stream = require("node:stream");
|
|
5782
|
-
var DEFAULT_INHERITED_ENV_VARS =
|
|
8082
|
+
var DEFAULT_INHERITED_ENV_VARS = import_node_process5.default.platform === "win32" ? [
|
|
5783
8083
|
"APPDATA",
|
|
5784
8084
|
"HOMEDRIVE",
|
|
5785
8085
|
"HOMEPATH",
|
|
@@ -5799,7 +8099,7 @@ var DEFAULT_INHERITED_ENV_VARS = import_node_process4.default.platform === "win3
|
|
|
5799
8099
|
function getDefaultEnvironment() {
|
|
5800
8100
|
const env = {};
|
|
5801
8101
|
for (const key of DEFAULT_INHERITED_ENV_VARS) {
|
|
5802
|
-
const value =
|
|
8102
|
+
const value = import_node_process5.default.env[key];
|
|
5803
8103
|
if (value === void 0) {
|
|
5804
8104
|
continue;
|
|
5805
8105
|
}
|
|
@@ -5835,7 +8135,7 @@ var StdioClientTransport = class {
|
|
|
5835
8135
|
},
|
|
5836
8136
|
stdio: ["pipe", "pipe", this._serverParams.stderr ?? "inherit"],
|
|
5837
8137
|
shell: false,
|
|
5838
|
-
windowsHide:
|
|
8138
|
+
windowsHide: import_node_process5.default.platform === "win32" && isElectron(),
|
|
5839
8139
|
cwd: this._serverParams.cwd
|
|
5840
8140
|
});
|
|
5841
8141
|
this._process.on("error", (error) => {
|
|
@@ -5943,7 +8243,7 @@ var StdioClientTransport = class {
|
|
|
5943
8243
|
}
|
|
5944
8244
|
};
|
|
5945
8245
|
function isElectron() {
|
|
5946
|
-
return "type" in
|
|
8246
|
+
return "type" in import_node_process5.default;
|
|
5947
8247
|
}
|
|
5948
8248
|
|
|
5949
8249
|
// __mcpc__cli_latest/node_modules/eventsource-parser/dist/index.js
|
|
@@ -7824,8 +10124,8 @@ var InMemoryTransport = class _InMemoryTransport {
|
|
|
7824
10124
|
};
|
|
7825
10125
|
|
|
7826
10126
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/config.js
|
|
7827
|
-
var
|
|
7828
|
-
var GEMINI_PREFERRED_FORMAT =
|
|
10127
|
+
var import_node_process6 = __toESM(require("node:process"), 1);
|
|
10128
|
+
var GEMINI_PREFERRED_FORMAT = import_node_process6.default.env.GEMINI_PREFERRED_FORMAT === "0" ? false : true;
|
|
7829
10129
|
|
|
7830
10130
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/json.js
|
|
7831
10131
|
var import_jsonrepair2 = require("jsonrepair");
|
|
@@ -7897,8 +10197,8 @@ var cleanToolSchema = (schema) => {
|
|
|
7897
10197
|
};
|
|
7898
10198
|
|
|
7899
10199
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/mcp.js
|
|
7900
|
-
var
|
|
7901
|
-
var
|
|
10200
|
+
var import_node_process7 = require("node:process");
|
|
10201
|
+
var import_node_process8 = __toESM(require("node:process"), 1);
|
|
7902
10202
|
var import_node_crypto = require("node:crypto");
|
|
7903
10203
|
var mcpClientPool = /* @__PURE__ */ new Map();
|
|
7904
10204
|
var mcpClientConnecting = /* @__PURE__ */ new Map();
|
|
@@ -7951,10 +10251,10 @@ function createTransport(def) {
|
|
|
7951
10251
|
command: defAny.command,
|
|
7952
10252
|
args: defAny.args,
|
|
7953
10253
|
env: {
|
|
7954
|
-
...
|
|
10254
|
+
...import_node_process8.default.env,
|
|
7955
10255
|
...defAny.env ?? {}
|
|
7956
10256
|
},
|
|
7957
|
-
cwd: (0,
|
|
10257
|
+
cwd: (0, import_node_process7.cwd)()
|
|
7958
10258
|
});
|
|
7959
10259
|
}
|
|
7960
10260
|
throw new Error(`Unsupported transport configuration: ${JSON.stringify(def)}`);
|
|
@@ -8019,11 +10319,11 @@ var cleanupAllPooledClients = async () => {
|
|
|
8019
10319
|
}
|
|
8020
10320
|
}));
|
|
8021
10321
|
};
|
|
8022
|
-
|
|
10322
|
+
import_node_process8.default.once?.("exit", () => {
|
|
8023
10323
|
cleanupAllPooledClients();
|
|
8024
10324
|
});
|
|
8025
|
-
|
|
8026
|
-
cleanupAllPooledClients().finally(() =>
|
|
10325
|
+
import_node_process8.default.once?.("SIGINT", () => {
|
|
10326
|
+
cleanupAllPooledClients().finally(() => import_node_process8.default.exit(0));
|
|
8027
10327
|
});
|
|
8028
10328
|
async function composeMcpDepTools(mcpConfig, filterIn) {
|
|
8029
10329
|
const allTools = {};
|
|
@@ -8645,7 +10945,7 @@ function endSpan(span, error) {
|
|
|
8645
10945
|
}
|
|
8646
10946
|
|
|
8647
10947
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/executors/agentic/agentic-executor.js
|
|
8648
|
-
var
|
|
10948
|
+
var import_node_process9 = __toESM(require("node:process"), 1);
|
|
8649
10949
|
var AgenticExecutor = class {
|
|
8650
10950
|
name;
|
|
8651
10951
|
allToolNames;
|
|
@@ -8665,13 +10965,13 @@ var AgenticExecutor = class {
|
|
|
8665
10965
|
this.logger = createLogger(`mcpc.agentic.${name}`, server);
|
|
8666
10966
|
this.toolSchemaMap = new Map(toolNameToDetailList);
|
|
8667
10967
|
try {
|
|
8668
|
-
this.tracingEnabled =
|
|
10968
|
+
this.tracingEnabled = import_node_process9.default.env.MCPC_TRACING_ENABLED === "true";
|
|
8669
10969
|
if (this.tracingEnabled) {
|
|
8670
10970
|
initializeTracing({
|
|
8671
10971
|
enabled: true,
|
|
8672
10972
|
serviceName: `mcpc-agentic-${name}`,
|
|
8673
|
-
exportTo:
|
|
8674
|
-
otlpEndpoint:
|
|
10973
|
+
exportTo: import_node_process9.default.env.MCPC_TRACING_EXPORT ?? "otlp",
|
|
10974
|
+
otlpEndpoint: import_node_process9.default.env.MCPC_TRACING_OTLP_ENDPOINT ?? "http://localhost:4318/v1/traces"
|
|
8675
10975
|
});
|
|
8676
10976
|
}
|
|
8677
10977
|
} catch {
|
|
@@ -9997,7 +12297,7 @@ async function loadPlugin(pluginPath, options = {
|
|
|
9997
12297
|
const importPath = typeof resolveFn === "function" ? resolveFn(rawPath) : new URL(rawPath, import_meta.url).href;
|
|
9998
12298
|
const pluginModule = await import(importPath);
|
|
9999
12299
|
const pluginFactory = pluginModule.createPlugin;
|
|
10000
|
-
const
|
|
12300
|
+
const defaultPlugin2 = pluginModule.default;
|
|
10001
12301
|
let plugin;
|
|
10002
12302
|
if (Object.keys(params).length > 0) {
|
|
10003
12303
|
if (typeof pluginFactory !== "function") {
|
|
@@ -10006,8 +12306,8 @@ async function loadPlugin(pluginPath, options = {
|
|
|
10006
12306
|
const typedParams = parseQueryParams(params);
|
|
10007
12307
|
plugin = pluginFactory(typedParams);
|
|
10008
12308
|
} else {
|
|
10009
|
-
if (
|
|
10010
|
-
plugin =
|
|
12309
|
+
if (defaultPlugin2) {
|
|
12310
|
+
plugin = defaultPlugin2;
|
|
10011
12311
|
} else if (typeof pluginFactory === "function") {
|
|
10012
12312
|
plugin = pluginFactory();
|
|
10013
12313
|
} else {
|
|
@@ -10708,6 +13008,7 @@ var ComposableMCPServer = class extends Server {
|
|
|
10708
13008
|
pluginManager;
|
|
10709
13009
|
toolManager;
|
|
10710
13010
|
logger = createLogger("mcpc.compose");
|
|
13011
|
+
fileLoaders = /* @__PURE__ */ new Map();
|
|
10711
13012
|
// Legacy property for backward compatibility
|
|
10712
13013
|
get toolNameMapping() {
|
|
10713
13014
|
return this.toolManager.getToolNameMapping();
|
|
@@ -10726,6 +13027,58 @@ var ComposableMCPServer = class extends Server {
|
|
|
10726
13027
|
this.pluginManager = new PluginManager(this);
|
|
10727
13028
|
this.toolManager = new ToolManager();
|
|
10728
13029
|
}
|
|
13030
|
+
/**
|
|
13031
|
+
* Register a file loader for a specific extension.
|
|
13032
|
+
* Plugins can use this to add support for different file formats.
|
|
13033
|
+
*
|
|
13034
|
+
* @param extension - File extension including the dot (e.g., ".md", ".yaml")
|
|
13035
|
+
* @param loader - Function that loads a file and returns a ComposeDefinition
|
|
13036
|
+
*
|
|
13037
|
+
* @example
|
|
13038
|
+
* ```typescript
|
|
13039
|
+
* // In a plugin's configureServer hook:
|
|
13040
|
+
* configureServer: (server) => {
|
|
13041
|
+
* server.registerFileLoader(".md", loadMarkdownAgentFile);
|
|
13042
|
+
* server.registerFileLoader(".yaml", loadYamlAgentFile);
|
|
13043
|
+
* }
|
|
13044
|
+
* ```
|
|
13045
|
+
*/
|
|
13046
|
+
registerFileLoader(extension, loader) {
|
|
13047
|
+
this.fileLoaders.set(extension.toLowerCase(), loader);
|
|
13048
|
+
}
|
|
13049
|
+
/**
|
|
13050
|
+
* Get the file loader for a specific extension.
|
|
13051
|
+
*/
|
|
13052
|
+
getFileLoader(extension) {
|
|
13053
|
+
return this.fileLoaders.get(extension.toLowerCase());
|
|
13054
|
+
}
|
|
13055
|
+
/**
|
|
13056
|
+
* Check if a file extension has a registered loader.
|
|
13057
|
+
*/
|
|
13058
|
+
hasFileLoader(extension) {
|
|
13059
|
+
return this.fileLoaders.has(extension.toLowerCase());
|
|
13060
|
+
}
|
|
13061
|
+
/**
|
|
13062
|
+
* Get all registered file extensions.
|
|
13063
|
+
*/
|
|
13064
|
+
getRegisteredExtensions() {
|
|
13065
|
+
return Array.from(this.fileLoaders.keys());
|
|
13066
|
+
}
|
|
13067
|
+
/**
|
|
13068
|
+
* Resolve a file path to a ComposeDefinition using registered loaders.
|
|
13069
|
+
* @internal
|
|
13070
|
+
*/
|
|
13071
|
+
async resolveFilePath(filePath) {
|
|
13072
|
+
const lastDot = filePath.lastIndexOf(".");
|
|
13073
|
+
const extension = lastDot === -1 ? "" : filePath.slice(lastDot).toLowerCase();
|
|
13074
|
+
const loader = this.fileLoaders.get(extension);
|
|
13075
|
+
if (!loader) {
|
|
13076
|
+
const supportedExtensions = this.getRegisteredExtensions().join(", ");
|
|
13077
|
+
const hint = supportedExtensions ? ` Supported extensions: ${supportedExtensions}.` : ' No file loaders registered. Use a loader plugin (e.g., markdownLoaderPlugin from "@mcpc/plugin-markdown-loader").';
|
|
13078
|
+
throw new Error(`Cannot load file "${filePath}": No loader registered for "${extension}" extension.${hint}`);
|
|
13079
|
+
}
|
|
13080
|
+
return await loader(filePath);
|
|
13081
|
+
}
|
|
10729
13082
|
/**
|
|
10730
13083
|
* Initialize built-in plugins - called during setup
|
|
10731
13084
|
*/
|
|
@@ -11270,32 +13623,16 @@ var ComposableMCPServer = class extends Server {
|
|
|
11270
13623
|
};
|
|
11271
13624
|
|
|
11272
13625
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/env.js
|
|
11273
|
-
var
|
|
11274
|
-
var isSCF = () => Boolean(
|
|
13626
|
+
var import_node_process10 = __toESM(require("node:process"), 1);
|
|
13627
|
+
var isSCF = () => Boolean(import_node_process10.default.env.SCF_RUNTIME || import_node_process10.default.env.PROD_SCF);
|
|
11275
13628
|
if (isSCF()) {
|
|
11276
13629
|
console.log({
|
|
11277
13630
|
isSCF: isSCF(),
|
|
11278
|
-
SCF_RUNTIME:
|
|
13631
|
+
SCF_RUNTIME: import_node_process10.default.env.SCF_RUNTIME
|
|
11279
13632
|
});
|
|
11280
13633
|
}
|
|
11281
13634
|
|
|
11282
13635
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/set-up-mcp-compose.js
|
|
11283
|
-
var markdownAgentLoader = null;
|
|
11284
|
-
function isMarkdownFile2(path) {
|
|
11285
|
-
return path.endsWith(".md") || path.endsWith(".markdown");
|
|
11286
|
-
}
|
|
11287
|
-
async function resolveComposeInput(input) {
|
|
11288
|
-
if (typeof input !== "string") {
|
|
11289
|
-
return input;
|
|
11290
|
-
}
|
|
11291
|
-
if (!isMarkdownFile2(input)) {
|
|
11292
|
-
throw new Error(`Invalid compose input: "${input}". Expected a Markdown file path (.md) or a ComposeDefinition object.`);
|
|
11293
|
-
}
|
|
11294
|
-
if (!markdownAgentLoader) {
|
|
11295
|
-
throw new Error(`Cannot load Markdown agent file "${input}": Markdown loader not available. Use markdownLoaderPlugin() from "@mcpc/plugin-markdown-loader", or use inline ComposeDefinition objects.`);
|
|
11296
|
-
}
|
|
11297
|
-
return await markdownAgentLoader(input);
|
|
11298
|
-
}
|
|
11299
13636
|
function parseMcpcConfigs(conf) {
|
|
11300
13637
|
return conf ?? [];
|
|
11301
13638
|
}
|
|
@@ -11313,7 +13650,13 @@ async function mcpc(serverConf, composeConf, optionsOrSetup) {
|
|
|
11313
13650
|
}
|
|
11314
13651
|
}
|
|
11315
13652
|
}
|
|
11316
|
-
const
|
|
13653
|
+
const resolveInput = (input) => {
|
|
13654
|
+
if (typeof input !== "string") {
|
|
13655
|
+
return Promise.resolve(input);
|
|
13656
|
+
}
|
|
13657
|
+
return server.resolveFilePath(input);
|
|
13658
|
+
};
|
|
13659
|
+
const resolvedConfigs = composeConf ? await Promise.all(composeConf.map(resolveInput)) : [];
|
|
11317
13660
|
const parsed = parseMcpcConfigs(resolvedConfigs);
|
|
11318
13661
|
await server.initBuiltInPlugins();
|
|
11319
13662
|
for (const mcpcConfig of parsed) {
|