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