deepfish-ai 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  "use strict";
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
@@ -29,6 +30,2801 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
29
30
  mod
30
31
  ));
31
32
 
33
+ // node_modules/js-yaml/lib/common.js
34
+ var require_common = __commonJS({
35
+ "node_modules/js-yaml/lib/common.js"(exports2, module2) {
36
+ "use strict";
37
+ function isNothing(subject) {
38
+ return typeof subject === "undefined" || subject === null;
39
+ }
40
+ function isObject2(subject) {
41
+ return typeof subject === "object" && subject !== null;
42
+ }
43
+ function toArray(sequence) {
44
+ if (Array.isArray(sequence)) return sequence;
45
+ else if (isNothing(sequence)) return [];
46
+ return [sequence];
47
+ }
48
+ function extend2(target, source) {
49
+ var index, length, key, sourceKeys;
50
+ if (source) {
51
+ sourceKeys = Object.keys(source);
52
+ for (index = 0, length = sourceKeys.length; index < length; index += 1) {
53
+ key = sourceKeys[index];
54
+ target[key] = source[key];
55
+ }
56
+ }
57
+ return target;
58
+ }
59
+ function repeat(string4, count) {
60
+ var result = "", cycle;
61
+ for (cycle = 0; cycle < count; cycle += 1) {
62
+ result += string4;
63
+ }
64
+ return result;
65
+ }
66
+ function isNegativeZero(number4) {
67
+ return number4 === 0 && Number.NEGATIVE_INFINITY === 1 / number4;
68
+ }
69
+ module2.exports.isNothing = isNothing;
70
+ module2.exports.isObject = isObject2;
71
+ module2.exports.toArray = toArray;
72
+ module2.exports.repeat = repeat;
73
+ module2.exports.isNegativeZero = isNegativeZero;
74
+ module2.exports.extend = extend2;
75
+ }
76
+ });
77
+
78
+ // node_modules/js-yaml/lib/exception.js
79
+ var require_exception = __commonJS({
80
+ "node_modules/js-yaml/lib/exception.js"(exports2, module2) {
81
+ "use strict";
82
+ function formatError2(exception, compact) {
83
+ var where = "", message = exception.reason || "(unknown reason)";
84
+ if (!exception.mark) return message;
85
+ if (exception.mark.name) {
86
+ where += 'in "' + exception.mark.name + '" ';
87
+ }
88
+ where += "(" + (exception.mark.line + 1) + ":" + (exception.mark.column + 1) + ")";
89
+ if (!compact && exception.mark.snippet) {
90
+ where += "\n\n" + exception.mark.snippet;
91
+ }
92
+ return message + " " + where;
93
+ }
94
+ function YAMLException(reason, mark) {
95
+ Error.call(this);
96
+ this.name = "YAMLException";
97
+ this.reason = reason;
98
+ this.mark = mark;
99
+ this.message = formatError2(this, false);
100
+ if (Error.captureStackTrace) {
101
+ Error.captureStackTrace(this, this.constructor);
102
+ } else {
103
+ this.stack = new Error().stack || "";
104
+ }
105
+ }
106
+ YAMLException.prototype = Object.create(Error.prototype);
107
+ YAMLException.prototype.constructor = YAMLException;
108
+ YAMLException.prototype.toString = function toString(compact) {
109
+ return this.name + ": " + formatError2(this, compact);
110
+ };
111
+ module2.exports = YAMLException;
112
+ }
113
+ });
114
+
115
+ // node_modules/js-yaml/lib/snippet.js
116
+ var require_snippet = __commonJS({
117
+ "node_modules/js-yaml/lib/snippet.js"(exports2, module2) {
118
+ "use strict";
119
+ var common = require_common();
120
+ function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
121
+ var head = "";
122
+ var tail = "";
123
+ var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
124
+ if (position - lineStart > maxHalfLength) {
125
+ head = " ... ";
126
+ lineStart = position - maxHalfLength + head.length;
127
+ }
128
+ if (lineEnd - position > maxHalfLength) {
129
+ tail = " ...";
130
+ lineEnd = position + maxHalfLength - tail.length;
131
+ }
132
+ return {
133
+ str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "\u2192") + tail,
134
+ pos: position - lineStart + head.length
135
+ // relative position
136
+ };
137
+ }
138
+ function padStart(string4, max) {
139
+ return common.repeat(" ", max - string4.length) + string4;
140
+ }
141
+ function makeSnippet(mark, options) {
142
+ options = Object.create(options || null);
143
+ if (!mark.buffer) return null;
144
+ if (!options.maxLength) options.maxLength = 79;
145
+ if (typeof options.indent !== "number") options.indent = 1;
146
+ if (typeof options.linesBefore !== "number") options.linesBefore = 3;
147
+ if (typeof options.linesAfter !== "number") options.linesAfter = 2;
148
+ var re = /\r?\n|\r|\0/g;
149
+ var lineStarts = [0];
150
+ var lineEnds = [];
151
+ var match;
152
+ var foundLineNo = -1;
153
+ while (match = re.exec(mark.buffer)) {
154
+ lineEnds.push(match.index);
155
+ lineStarts.push(match.index + match[0].length);
156
+ if (mark.position <= match.index && foundLineNo < 0) {
157
+ foundLineNo = lineStarts.length - 2;
158
+ }
159
+ }
160
+ if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
161
+ var result = "", i, line;
162
+ var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
163
+ var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
164
+ for (i = 1; i <= options.linesBefore; i++) {
165
+ if (foundLineNo - i < 0) break;
166
+ line = getLine(
167
+ mark.buffer,
168
+ lineStarts[foundLineNo - i],
169
+ lineEnds[foundLineNo - i],
170
+ mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]),
171
+ maxLineLength
172
+ );
173
+ result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result;
174
+ }
175
+ line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
176
+ result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n";
177
+ result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n";
178
+ for (i = 1; i <= options.linesAfter; i++) {
179
+ if (foundLineNo + i >= lineEnds.length) break;
180
+ line = getLine(
181
+ mark.buffer,
182
+ lineStarts[foundLineNo + i],
183
+ lineEnds[foundLineNo + i],
184
+ mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]),
185
+ maxLineLength
186
+ );
187
+ result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + "\n";
188
+ }
189
+ return result.replace(/\n$/, "");
190
+ }
191
+ module2.exports = makeSnippet;
192
+ }
193
+ });
194
+
195
+ // node_modules/js-yaml/lib/type.js
196
+ var require_type = __commonJS({
197
+ "node_modules/js-yaml/lib/type.js"(exports2, module2) {
198
+ "use strict";
199
+ var YAMLException = require_exception();
200
+ var TYPE_CONSTRUCTOR_OPTIONS = [
201
+ "kind",
202
+ "multi",
203
+ "resolve",
204
+ "construct",
205
+ "instanceOf",
206
+ "predicate",
207
+ "represent",
208
+ "representName",
209
+ "defaultStyle",
210
+ "styleAliases"
211
+ ];
212
+ var YAML_NODE_KINDS = [
213
+ "scalar",
214
+ "sequence",
215
+ "mapping"
216
+ ];
217
+ function compileStyleAliases(map2) {
218
+ var result = {};
219
+ if (map2 !== null) {
220
+ Object.keys(map2).forEach(function(style) {
221
+ map2[style].forEach(function(alias) {
222
+ result[String(alias)] = style;
223
+ });
224
+ });
225
+ }
226
+ return result;
227
+ }
228
+ function Type(tag, options) {
229
+ options = options || {};
230
+ Object.keys(options).forEach(function(name) {
231
+ if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
232
+ throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
233
+ }
234
+ });
235
+ this.options = options;
236
+ this.tag = tag;
237
+ this.kind = options["kind"] || null;
238
+ this.resolve = options["resolve"] || function() {
239
+ return true;
240
+ };
241
+ this.construct = options["construct"] || function(data) {
242
+ return data;
243
+ };
244
+ this.instanceOf = options["instanceOf"] || null;
245
+ this.predicate = options["predicate"] || null;
246
+ this.represent = options["represent"] || null;
247
+ this.representName = options["representName"] || null;
248
+ this.defaultStyle = options["defaultStyle"] || null;
249
+ this.multi = options["multi"] || false;
250
+ this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
251
+ if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
252
+ throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
253
+ }
254
+ }
255
+ module2.exports = Type;
256
+ }
257
+ });
258
+
259
+ // node_modules/js-yaml/lib/schema.js
260
+ var require_schema = __commonJS({
261
+ "node_modules/js-yaml/lib/schema.js"(exports2, module2) {
262
+ "use strict";
263
+ var YAMLException = require_exception();
264
+ var Type = require_type();
265
+ function compileList(schema, name) {
266
+ var result = [];
267
+ schema[name].forEach(function(currentType) {
268
+ var newIndex = result.length;
269
+ result.forEach(function(previousType, previousIndex) {
270
+ if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
271
+ newIndex = previousIndex;
272
+ }
273
+ });
274
+ result[newIndex] = currentType;
275
+ });
276
+ return result;
277
+ }
278
+ function compileMap() {
279
+ var result = {
280
+ scalar: {},
281
+ sequence: {},
282
+ mapping: {},
283
+ fallback: {},
284
+ multi: {
285
+ scalar: [],
286
+ sequence: [],
287
+ mapping: [],
288
+ fallback: []
289
+ }
290
+ }, index, length;
291
+ function collectType(type) {
292
+ if (type.multi) {
293
+ result.multi[type.kind].push(type);
294
+ result.multi["fallback"].push(type);
295
+ } else {
296
+ result[type.kind][type.tag] = result["fallback"][type.tag] = type;
297
+ }
298
+ }
299
+ for (index = 0, length = arguments.length; index < length; index += 1) {
300
+ arguments[index].forEach(collectType);
301
+ }
302
+ return result;
303
+ }
304
+ function Schema(definition) {
305
+ return this.extend(definition);
306
+ }
307
+ Schema.prototype.extend = function extend2(definition) {
308
+ var implicit = [];
309
+ var explicit = [];
310
+ if (definition instanceof Type) {
311
+ explicit.push(definition);
312
+ } else if (Array.isArray(definition)) {
313
+ explicit = explicit.concat(definition);
314
+ } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
315
+ if (definition.implicit) implicit = implicit.concat(definition.implicit);
316
+ if (definition.explicit) explicit = explicit.concat(definition.explicit);
317
+ } else {
318
+ throw new YAMLException("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");
319
+ }
320
+ implicit.forEach(function(type) {
321
+ if (!(type instanceof Type)) {
322
+ throw new YAMLException("Specified list of YAML types (or a single Type object) contains a non-Type object.");
323
+ }
324
+ if (type.loadKind && type.loadKind !== "scalar") {
325
+ throw new YAMLException("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
326
+ }
327
+ if (type.multi) {
328
+ throw new YAMLException("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
329
+ }
330
+ });
331
+ explicit.forEach(function(type) {
332
+ if (!(type instanceof Type)) {
333
+ throw new YAMLException("Specified list of YAML types (or a single Type object) contains a non-Type object.");
334
+ }
335
+ });
336
+ var result = Object.create(Schema.prototype);
337
+ result.implicit = (this.implicit || []).concat(implicit);
338
+ result.explicit = (this.explicit || []).concat(explicit);
339
+ result.compiledImplicit = compileList(result, "implicit");
340
+ result.compiledExplicit = compileList(result, "explicit");
341
+ result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
342
+ return result;
343
+ };
344
+ module2.exports = Schema;
345
+ }
346
+ });
347
+
348
+ // node_modules/js-yaml/lib/type/str.js
349
+ var require_str = __commonJS({
350
+ "node_modules/js-yaml/lib/type/str.js"(exports2, module2) {
351
+ "use strict";
352
+ var Type = require_type();
353
+ module2.exports = new Type("tag:yaml.org,2002:str", {
354
+ kind: "scalar",
355
+ construct: function(data) {
356
+ return data !== null ? data : "";
357
+ }
358
+ });
359
+ }
360
+ });
361
+
362
+ // node_modules/js-yaml/lib/type/seq.js
363
+ var require_seq = __commonJS({
364
+ "node_modules/js-yaml/lib/type/seq.js"(exports2, module2) {
365
+ "use strict";
366
+ var Type = require_type();
367
+ module2.exports = new Type("tag:yaml.org,2002:seq", {
368
+ kind: "sequence",
369
+ construct: function(data) {
370
+ return data !== null ? data : [];
371
+ }
372
+ });
373
+ }
374
+ });
375
+
376
+ // node_modules/js-yaml/lib/type/map.js
377
+ var require_map = __commonJS({
378
+ "node_modules/js-yaml/lib/type/map.js"(exports2, module2) {
379
+ "use strict";
380
+ var Type = require_type();
381
+ module2.exports = new Type("tag:yaml.org,2002:map", {
382
+ kind: "mapping",
383
+ construct: function(data) {
384
+ return data !== null ? data : {};
385
+ }
386
+ });
387
+ }
388
+ });
389
+
390
+ // node_modules/js-yaml/lib/schema/failsafe.js
391
+ var require_failsafe = __commonJS({
392
+ "node_modules/js-yaml/lib/schema/failsafe.js"(exports2, module2) {
393
+ "use strict";
394
+ var Schema = require_schema();
395
+ module2.exports = new Schema({
396
+ explicit: [
397
+ require_str(),
398
+ require_seq(),
399
+ require_map()
400
+ ]
401
+ });
402
+ }
403
+ });
404
+
405
+ // node_modules/js-yaml/lib/type/null.js
406
+ var require_null = __commonJS({
407
+ "node_modules/js-yaml/lib/type/null.js"(exports2, module2) {
408
+ "use strict";
409
+ var Type = require_type();
410
+ function resolveYamlNull(data) {
411
+ if (data === null) return true;
412
+ var max = data.length;
413
+ return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
414
+ }
415
+ function constructYamlNull() {
416
+ return null;
417
+ }
418
+ function isNull(object2) {
419
+ return object2 === null;
420
+ }
421
+ module2.exports = new Type("tag:yaml.org,2002:null", {
422
+ kind: "scalar",
423
+ resolve: resolveYamlNull,
424
+ construct: constructYamlNull,
425
+ predicate: isNull,
426
+ represent: {
427
+ canonical: function() {
428
+ return "~";
429
+ },
430
+ lowercase: function() {
431
+ return "null";
432
+ },
433
+ uppercase: function() {
434
+ return "NULL";
435
+ },
436
+ camelcase: function() {
437
+ return "Null";
438
+ },
439
+ empty: function() {
440
+ return "";
441
+ }
442
+ },
443
+ defaultStyle: "lowercase"
444
+ });
445
+ }
446
+ });
447
+
448
+ // node_modules/js-yaml/lib/type/bool.js
449
+ var require_bool = __commonJS({
450
+ "node_modules/js-yaml/lib/type/bool.js"(exports2, module2) {
451
+ "use strict";
452
+ var Type = require_type();
453
+ function resolveYamlBoolean(data) {
454
+ if (data === null) return false;
455
+ var max = data.length;
456
+ return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
457
+ }
458
+ function constructYamlBoolean(data) {
459
+ return data === "true" || data === "True" || data === "TRUE";
460
+ }
461
+ function isBoolean(object2) {
462
+ return Object.prototype.toString.call(object2) === "[object Boolean]";
463
+ }
464
+ module2.exports = new Type("tag:yaml.org,2002:bool", {
465
+ kind: "scalar",
466
+ resolve: resolveYamlBoolean,
467
+ construct: constructYamlBoolean,
468
+ predicate: isBoolean,
469
+ represent: {
470
+ lowercase: function(object2) {
471
+ return object2 ? "true" : "false";
472
+ },
473
+ uppercase: function(object2) {
474
+ return object2 ? "TRUE" : "FALSE";
475
+ },
476
+ camelcase: function(object2) {
477
+ return object2 ? "True" : "False";
478
+ }
479
+ },
480
+ defaultStyle: "lowercase"
481
+ });
482
+ }
483
+ });
484
+
485
+ // node_modules/js-yaml/lib/type/int.js
486
+ var require_int = __commonJS({
487
+ "node_modules/js-yaml/lib/type/int.js"(exports2, module2) {
488
+ "use strict";
489
+ var common = require_common();
490
+ var Type = require_type();
491
+ function isHexCode(c) {
492
+ return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
493
+ }
494
+ function isOctCode(c) {
495
+ return 48 <= c && c <= 55;
496
+ }
497
+ function isDecCode(c) {
498
+ return 48 <= c && c <= 57;
499
+ }
500
+ function resolveYamlInteger(data) {
501
+ if (data === null) return false;
502
+ var max = data.length, index = 0, hasDigits = false, ch;
503
+ if (!max) return false;
504
+ ch = data[index];
505
+ if (ch === "-" || ch === "+") {
506
+ ch = data[++index];
507
+ }
508
+ if (ch === "0") {
509
+ if (index + 1 === max) return true;
510
+ ch = data[++index];
511
+ if (ch === "b") {
512
+ index++;
513
+ for (; index < max; index++) {
514
+ ch = data[index];
515
+ if (ch === "_") continue;
516
+ if (ch !== "0" && ch !== "1") return false;
517
+ hasDigits = true;
518
+ }
519
+ return hasDigits && ch !== "_";
520
+ }
521
+ if (ch === "x") {
522
+ index++;
523
+ for (; index < max; index++) {
524
+ ch = data[index];
525
+ if (ch === "_") continue;
526
+ if (!isHexCode(data.charCodeAt(index))) return false;
527
+ hasDigits = true;
528
+ }
529
+ return hasDigits && ch !== "_";
530
+ }
531
+ if (ch === "o") {
532
+ index++;
533
+ for (; index < max; index++) {
534
+ ch = data[index];
535
+ if (ch === "_") continue;
536
+ if (!isOctCode(data.charCodeAt(index))) return false;
537
+ hasDigits = true;
538
+ }
539
+ return hasDigits && ch !== "_";
540
+ }
541
+ }
542
+ if (ch === "_") return false;
543
+ for (; index < max; index++) {
544
+ ch = data[index];
545
+ if (ch === "_") continue;
546
+ if (!isDecCode(data.charCodeAt(index))) {
547
+ return false;
548
+ }
549
+ hasDigits = true;
550
+ }
551
+ if (!hasDigits || ch === "_") return false;
552
+ return true;
553
+ }
554
+ function constructYamlInteger(data) {
555
+ var value = data, sign = 1, ch;
556
+ if (value.indexOf("_") !== -1) {
557
+ value = value.replace(/_/g, "");
558
+ }
559
+ ch = value[0];
560
+ if (ch === "-" || ch === "+") {
561
+ if (ch === "-") sign = -1;
562
+ value = value.slice(1);
563
+ ch = value[0];
564
+ }
565
+ if (value === "0") return 0;
566
+ if (ch === "0") {
567
+ if (value[1] === "b") return sign * parseInt(value.slice(2), 2);
568
+ if (value[1] === "x") return sign * parseInt(value.slice(2), 16);
569
+ if (value[1] === "o") return sign * parseInt(value.slice(2), 8);
570
+ }
571
+ return sign * parseInt(value, 10);
572
+ }
573
+ function isInteger(object2) {
574
+ return Object.prototype.toString.call(object2) === "[object Number]" && (object2 % 1 === 0 && !common.isNegativeZero(object2));
575
+ }
576
+ module2.exports = new Type("tag:yaml.org,2002:int", {
577
+ kind: "scalar",
578
+ resolve: resolveYamlInteger,
579
+ construct: constructYamlInteger,
580
+ predicate: isInteger,
581
+ represent: {
582
+ binary: function(obj) {
583
+ return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
584
+ },
585
+ octal: function(obj) {
586
+ return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
587
+ },
588
+ decimal: function(obj) {
589
+ return obj.toString(10);
590
+ },
591
+ /* eslint-disable max-len */
592
+ hexadecimal: function(obj) {
593
+ return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
594
+ }
595
+ },
596
+ defaultStyle: "decimal",
597
+ styleAliases: {
598
+ binary: [2, "bin"],
599
+ octal: [8, "oct"],
600
+ decimal: [10, "dec"],
601
+ hexadecimal: [16, "hex"]
602
+ }
603
+ });
604
+ }
605
+ });
606
+
607
+ // node_modules/js-yaml/lib/type/float.js
608
+ var require_float = __commonJS({
609
+ "node_modules/js-yaml/lib/type/float.js"(exports2, module2) {
610
+ "use strict";
611
+ var common = require_common();
612
+ var Type = require_type();
613
+ var YAML_FLOAT_PATTERN = new RegExp(
614
+ // 2.5e4, 2.5 and integers
615
+ "^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"
616
+ );
617
+ function resolveYamlFloat(data) {
618
+ if (data === null) return false;
619
+ if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_`
620
+ // Probably should update regexp & check speed
621
+ data[data.length - 1] === "_") {
622
+ return false;
623
+ }
624
+ return true;
625
+ }
626
+ function constructYamlFloat(data) {
627
+ var value, sign;
628
+ value = data.replace(/_/g, "").toLowerCase();
629
+ sign = value[0] === "-" ? -1 : 1;
630
+ if ("+-".indexOf(value[0]) >= 0) {
631
+ value = value.slice(1);
632
+ }
633
+ if (value === ".inf") {
634
+ return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
635
+ } else if (value === ".nan") {
636
+ return NaN;
637
+ }
638
+ return sign * parseFloat(value, 10);
639
+ }
640
+ var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
641
+ function representYamlFloat(object2, style) {
642
+ var res;
643
+ if (isNaN(object2)) {
644
+ switch (style) {
645
+ case "lowercase":
646
+ return ".nan";
647
+ case "uppercase":
648
+ return ".NAN";
649
+ case "camelcase":
650
+ return ".NaN";
651
+ }
652
+ } else if (Number.POSITIVE_INFINITY === object2) {
653
+ switch (style) {
654
+ case "lowercase":
655
+ return ".inf";
656
+ case "uppercase":
657
+ return ".INF";
658
+ case "camelcase":
659
+ return ".Inf";
660
+ }
661
+ } else if (Number.NEGATIVE_INFINITY === object2) {
662
+ switch (style) {
663
+ case "lowercase":
664
+ return "-.inf";
665
+ case "uppercase":
666
+ return "-.INF";
667
+ case "camelcase":
668
+ return "-.Inf";
669
+ }
670
+ } else if (common.isNegativeZero(object2)) {
671
+ return "-0.0";
672
+ }
673
+ res = object2.toString(10);
674
+ return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
675
+ }
676
+ function isFloat(object2) {
677
+ return Object.prototype.toString.call(object2) === "[object Number]" && (object2 % 1 !== 0 || common.isNegativeZero(object2));
678
+ }
679
+ module2.exports = new Type("tag:yaml.org,2002:float", {
680
+ kind: "scalar",
681
+ resolve: resolveYamlFloat,
682
+ construct: constructYamlFloat,
683
+ predicate: isFloat,
684
+ represent: representYamlFloat,
685
+ defaultStyle: "lowercase"
686
+ });
687
+ }
688
+ });
689
+
690
+ // node_modules/js-yaml/lib/schema/json.js
691
+ var require_json = __commonJS({
692
+ "node_modules/js-yaml/lib/schema/json.js"(exports2, module2) {
693
+ "use strict";
694
+ module2.exports = require_failsafe().extend({
695
+ implicit: [
696
+ require_null(),
697
+ require_bool(),
698
+ require_int(),
699
+ require_float()
700
+ ]
701
+ });
702
+ }
703
+ });
704
+
705
+ // node_modules/js-yaml/lib/schema/core.js
706
+ var require_core = __commonJS({
707
+ "node_modules/js-yaml/lib/schema/core.js"(exports2, module2) {
708
+ "use strict";
709
+ module2.exports = require_json();
710
+ }
711
+ });
712
+
713
+ // node_modules/js-yaml/lib/type/timestamp.js
714
+ var require_timestamp = __commonJS({
715
+ "node_modules/js-yaml/lib/type/timestamp.js"(exports2, module2) {
716
+ "use strict";
717
+ var Type = require_type();
718
+ var YAML_DATE_REGEXP = new RegExp(
719
+ "^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"
720
+ );
721
+ var YAML_TIMESTAMP_REGEXP = new RegExp(
722
+ "^([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]))?))?$"
723
+ );
724
+ function resolveYamlTimestamp(data) {
725
+ if (data === null) return false;
726
+ if (YAML_DATE_REGEXP.exec(data) !== null) return true;
727
+ if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
728
+ return false;
729
+ }
730
+ function constructYamlTimestamp(data) {
731
+ var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date5;
732
+ match = YAML_DATE_REGEXP.exec(data);
733
+ if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
734
+ if (match === null) throw new Error("Date resolve error");
735
+ year = +match[1];
736
+ month = +match[2] - 1;
737
+ day = +match[3];
738
+ if (!match[4]) {
739
+ return new Date(Date.UTC(year, month, day));
740
+ }
741
+ hour = +match[4];
742
+ minute = +match[5];
743
+ second = +match[6];
744
+ if (match[7]) {
745
+ fraction = match[7].slice(0, 3);
746
+ while (fraction.length < 3) {
747
+ fraction += "0";
748
+ }
749
+ fraction = +fraction;
750
+ }
751
+ if (match[9]) {
752
+ tz_hour = +match[10];
753
+ tz_minute = +(match[11] || 0);
754
+ delta = (tz_hour * 60 + tz_minute) * 6e4;
755
+ if (match[9] === "-") delta = -delta;
756
+ }
757
+ date5 = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
758
+ if (delta) date5.setTime(date5.getTime() - delta);
759
+ return date5;
760
+ }
761
+ function representYamlTimestamp(object2) {
762
+ return object2.toISOString();
763
+ }
764
+ module2.exports = new Type("tag:yaml.org,2002:timestamp", {
765
+ kind: "scalar",
766
+ resolve: resolveYamlTimestamp,
767
+ construct: constructYamlTimestamp,
768
+ instanceOf: Date,
769
+ represent: representYamlTimestamp
770
+ });
771
+ }
772
+ });
773
+
774
+ // node_modules/js-yaml/lib/type/merge.js
775
+ var require_merge = __commonJS({
776
+ "node_modules/js-yaml/lib/type/merge.js"(exports2, module2) {
777
+ "use strict";
778
+ var Type = require_type();
779
+ function resolveYamlMerge(data) {
780
+ return data === "<<" || data === null;
781
+ }
782
+ module2.exports = new Type("tag:yaml.org,2002:merge", {
783
+ kind: "scalar",
784
+ resolve: resolveYamlMerge
785
+ });
786
+ }
787
+ });
788
+
789
+ // node_modules/js-yaml/lib/type/binary.js
790
+ var require_binary = __commonJS({
791
+ "node_modules/js-yaml/lib/type/binary.js"(exports2, module2) {
792
+ "use strict";
793
+ var Type = require_type();
794
+ var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
795
+ function resolveYamlBinary(data) {
796
+ if (data === null) return false;
797
+ var code, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP;
798
+ for (idx = 0; idx < max; idx++) {
799
+ code = map2.indexOf(data.charAt(idx));
800
+ if (code > 64) continue;
801
+ if (code < 0) return false;
802
+ bitlen += 6;
803
+ }
804
+ return bitlen % 8 === 0;
805
+ }
806
+ function constructYamlBinary(data) {
807
+ var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map2 = BASE64_MAP, bits = 0, result = [];
808
+ for (idx = 0; idx < max; idx++) {
809
+ if (idx % 4 === 0 && idx) {
810
+ result.push(bits >> 16 & 255);
811
+ result.push(bits >> 8 & 255);
812
+ result.push(bits & 255);
813
+ }
814
+ bits = bits << 6 | map2.indexOf(input.charAt(idx));
815
+ }
816
+ tailbits = max % 4 * 6;
817
+ if (tailbits === 0) {
818
+ result.push(bits >> 16 & 255);
819
+ result.push(bits >> 8 & 255);
820
+ result.push(bits & 255);
821
+ } else if (tailbits === 18) {
822
+ result.push(bits >> 10 & 255);
823
+ result.push(bits >> 2 & 255);
824
+ } else if (tailbits === 12) {
825
+ result.push(bits >> 4 & 255);
826
+ }
827
+ return new Uint8Array(result);
828
+ }
829
+ function representYamlBinary(object2) {
830
+ var result = "", bits = 0, idx, tail, max = object2.length, map2 = BASE64_MAP;
831
+ for (idx = 0; idx < max; idx++) {
832
+ if (idx % 3 === 0 && idx) {
833
+ result += map2[bits >> 18 & 63];
834
+ result += map2[bits >> 12 & 63];
835
+ result += map2[bits >> 6 & 63];
836
+ result += map2[bits & 63];
837
+ }
838
+ bits = (bits << 8) + object2[idx];
839
+ }
840
+ tail = max % 3;
841
+ if (tail === 0) {
842
+ result += map2[bits >> 18 & 63];
843
+ result += map2[bits >> 12 & 63];
844
+ result += map2[bits >> 6 & 63];
845
+ result += map2[bits & 63];
846
+ } else if (tail === 2) {
847
+ result += map2[bits >> 10 & 63];
848
+ result += map2[bits >> 4 & 63];
849
+ result += map2[bits << 2 & 63];
850
+ result += map2[64];
851
+ } else if (tail === 1) {
852
+ result += map2[bits >> 2 & 63];
853
+ result += map2[bits << 4 & 63];
854
+ result += map2[64];
855
+ result += map2[64];
856
+ }
857
+ return result;
858
+ }
859
+ function isBinary(obj) {
860
+ return Object.prototype.toString.call(obj) === "[object Uint8Array]";
861
+ }
862
+ module2.exports = new Type("tag:yaml.org,2002:binary", {
863
+ kind: "scalar",
864
+ resolve: resolveYamlBinary,
865
+ construct: constructYamlBinary,
866
+ predicate: isBinary,
867
+ represent: representYamlBinary
868
+ });
869
+ }
870
+ });
871
+
872
+ // node_modules/js-yaml/lib/type/omap.js
873
+ var require_omap = __commonJS({
874
+ "node_modules/js-yaml/lib/type/omap.js"(exports2, module2) {
875
+ "use strict";
876
+ var Type = require_type();
877
+ var _hasOwnProperty = Object.prototype.hasOwnProperty;
878
+ var _toString = Object.prototype.toString;
879
+ function resolveYamlOmap(data) {
880
+ if (data === null) return true;
881
+ var objectKeys = [], index, length, pair, pairKey, pairHasKey, object2 = data;
882
+ for (index = 0, length = object2.length; index < length; index += 1) {
883
+ pair = object2[index];
884
+ pairHasKey = false;
885
+ if (_toString.call(pair) !== "[object Object]") return false;
886
+ for (pairKey in pair) {
887
+ if (_hasOwnProperty.call(pair, pairKey)) {
888
+ if (!pairHasKey) pairHasKey = true;
889
+ else return false;
890
+ }
891
+ }
892
+ if (!pairHasKey) return false;
893
+ if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
894
+ else return false;
895
+ }
896
+ return true;
897
+ }
898
+ function constructYamlOmap(data) {
899
+ return data !== null ? data : [];
900
+ }
901
+ module2.exports = new Type("tag:yaml.org,2002:omap", {
902
+ kind: "sequence",
903
+ resolve: resolveYamlOmap,
904
+ construct: constructYamlOmap
905
+ });
906
+ }
907
+ });
908
+
909
+ // node_modules/js-yaml/lib/type/pairs.js
910
+ var require_pairs = __commonJS({
911
+ "node_modules/js-yaml/lib/type/pairs.js"(exports2, module2) {
912
+ "use strict";
913
+ var Type = require_type();
914
+ var _toString = Object.prototype.toString;
915
+ function resolveYamlPairs(data) {
916
+ if (data === null) return true;
917
+ var index, length, pair, keys, result, object2 = data;
918
+ result = new Array(object2.length);
919
+ for (index = 0, length = object2.length; index < length; index += 1) {
920
+ pair = object2[index];
921
+ if (_toString.call(pair) !== "[object Object]") return false;
922
+ keys = Object.keys(pair);
923
+ if (keys.length !== 1) return false;
924
+ result[index] = [keys[0], pair[keys[0]]];
925
+ }
926
+ return true;
927
+ }
928
+ function constructYamlPairs(data) {
929
+ if (data === null) return [];
930
+ var index, length, pair, keys, result, object2 = data;
931
+ result = new Array(object2.length);
932
+ for (index = 0, length = object2.length; index < length; index += 1) {
933
+ pair = object2[index];
934
+ keys = Object.keys(pair);
935
+ result[index] = [keys[0], pair[keys[0]]];
936
+ }
937
+ return result;
938
+ }
939
+ module2.exports = new Type("tag:yaml.org,2002:pairs", {
940
+ kind: "sequence",
941
+ resolve: resolveYamlPairs,
942
+ construct: constructYamlPairs
943
+ });
944
+ }
945
+ });
946
+
947
+ // node_modules/js-yaml/lib/type/set.js
948
+ var require_set = __commonJS({
949
+ "node_modules/js-yaml/lib/type/set.js"(exports2, module2) {
950
+ "use strict";
951
+ var Type = require_type();
952
+ var _hasOwnProperty = Object.prototype.hasOwnProperty;
953
+ function resolveYamlSet(data) {
954
+ if (data === null) return true;
955
+ var key, object2 = data;
956
+ for (key in object2) {
957
+ if (_hasOwnProperty.call(object2, key)) {
958
+ if (object2[key] !== null) return false;
959
+ }
960
+ }
961
+ return true;
962
+ }
963
+ function constructYamlSet(data) {
964
+ return data !== null ? data : {};
965
+ }
966
+ module2.exports = new Type("tag:yaml.org,2002:set", {
967
+ kind: "mapping",
968
+ resolve: resolveYamlSet,
969
+ construct: constructYamlSet
970
+ });
971
+ }
972
+ });
973
+
974
+ // node_modules/js-yaml/lib/schema/default.js
975
+ var require_default = __commonJS({
976
+ "node_modules/js-yaml/lib/schema/default.js"(exports2, module2) {
977
+ "use strict";
978
+ module2.exports = require_core().extend({
979
+ implicit: [
980
+ require_timestamp(),
981
+ require_merge()
982
+ ],
983
+ explicit: [
984
+ require_binary(),
985
+ require_omap(),
986
+ require_pairs(),
987
+ require_set()
988
+ ]
989
+ });
990
+ }
991
+ });
992
+
993
+ // node_modules/js-yaml/lib/loader.js
994
+ var require_loader = __commonJS({
995
+ "node_modules/js-yaml/lib/loader.js"(exports2, module2) {
996
+ "use strict";
997
+ var common = require_common();
998
+ var YAMLException = require_exception();
999
+ var makeSnippet = require_snippet();
1000
+ var DEFAULT_SCHEMA = require_default();
1001
+ var _hasOwnProperty = Object.prototype.hasOwnProperty;
1002
+ var CONTEXT_FLOW_IN = 1;
1003
+ var CONTEXT_FLOW_OUT = 2;
1004
+ var CONTEXT_BLOCK_IN = 3;
1005
+ var CONTEXT_BLOCK_OUT = 4;
1006
+ var CHOMPING_CLIP = 1;
1007
+ var CHOMPING_STRIP = 2;
1008
+ var CHOMPING_KEEP = 3;
1009
+ var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
1010
+ var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
1011
+ var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
1012
+ var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
1013
+ var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
1014
+ function _class(obj) {
1015
+ return Object.prototype.toString.call(obj);
1016
+ }
1017
+ function is_EOL(c) {
1018
+ return c === 10 || c === 13;
1019
+ }
1020
+ function is_WHITE_SPACE(c) {
1021
+ return c === 9 || c === 32;
1022
+ }
1023
+ function is_WS_OR_EOL(c) {
1024
+ return c === 9 || c === 32 || c === 10 || c === 13;
1025
+ }
1026
+ function is_FLOW_INDICATOR(c) {
1027
+ return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
1028
+ }
1029
+ function fromHexCode(c) {
1030
+ var lc;
1031
+ if (48 <= c && c <= 57) {
1032
+ return c - 48;
1033
+ }
1034
+ lc = c | 32;
1035
+ if (97 <= lc && lc <= 102) {
1036
+ return lc - 97 + 10;
1037
+ }
1038
+ return -1;
1039
+ }
1040
+ function escapedHexLen(c) {
1041
+ if (c === 120) {
1042
+ return 2;
1043
+ }
1044
+ if (c === 117) {
1045
+ return 4;
1046
+ }
1047
+ if (c === 85) {
1048
+ return 8;
1049
+ }
1050
+ return 0;
1051
+ }
1052
+ function fromDecimalCode(c) {
1053
+ if (48 <= c && c <= 57) {
1054
+ return c - 48;
1055
+ }
1056
+ return -1;
1057
+ }
1058
+ function simpleEscapeSequence(c) {
1059
+ return c === 48 ? "\0" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? " " : c === 9 ? " " : c === 110 ? "\n" : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "\x85" : c === 95 ? "\xA0" : c === 76 ? "\u2028" : c === 80 ? "\u2029" : "";
1060
+ }
1061
+ function charFromCodepoint(c) {
1062
+ if (c <= 65535) {
1063
+ return String.fromCharCode(c);
1064
+ }
1065
+ return String.fromCharCode(
1066
+ (c - 65536 >> 10) + 55296,
1067
+ (c - 65536 & 1023) + 56320
1068
+ );
1069
+ }
1070
+ function setProperty(object2, key, value) {
1071
+ if (key === "__proto__") {
1072
+ Object.defineProperty(object2, key, {
1073
+ configurable: true,
1074
+ enumerable: true,
1075
+ writable: true,
1076
+ value
1077
+ });
1078
+ } else {
1079
+ object2[key] = value;
1080
+ }
1081
+ }
1082
+ var simpleEscapeCheck = new Array(256);
1083
+ var simpleEscapeMap = new Array(256);
1084
+ for (i = 0; i < 256; i++) {
1085
+ simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
1086
+ simpleEscapeMap[i] = simpleEscapeSequence(i);
1087
+ }
1088
+ var i;
1089
+ function State(input, options) {
1090
+ this.input = input;
1091
+ this.filename = options["filename"] || null;
1092
+ this.schema = options["schema"] || DEFAULT_SCHEMA;
1093
+ this.onWarning = options["onWarning"] || null;
1094
+ this.legacy = options["legacy"] || false;
1095
+ this.json = options["json"] || false;
1096
+ this.listener = options["listener"] || null;
1097
+ this.implicitTypes = this.schema.compiledImplicit;
1098
+ this.typeMap = this.schema.compiledTypeMap;
1099
+ this.length = input.length;
1100
+ this.position = 0;
1101
+ this.line = 0;
1102
+ this.lineStart = 0;
1103
+ this.lineIndent = 0;
1104
+ this.firstTabInLine = -1;
1105
+ this.documents = [];
1106
+ }
1107
+ function generateError(state, message) {
1108
+ var mark = {
1109
+ name: state.filename,
1110
+ buffer: state.input.slice(0, -1),
1111
+ // omit trailing \0
1112
+ position: state.position,
1113
+ line: state.line,
1114
+ column: state.position - state.lineStart
1115
+ };
1116
+ mark.snippet = makeSnippet(mark);
1117
+ return new YAMLException(message, mark);
1118
+ }
1119
+ function throwError(state, message) {
1120
+ throw generateError(state, message);
1121
+ }
1122
+ function throwWarning(state, message) {
1123
+ if (state.onWarning) {
1124
+ state.onWarning.call(null, generateError(state, message));
1125
+ }
1126
+ }
1127
+ var directiveHandlers = {
1128
+ YAML: function handleYamlDirective(state, name, args) {
1129
+ var match, major, minor;
1130
+ if (state.version !== null) {
1131
+ throwError(state, "duplication of %YAML directive");
1132
+ }
1133
+ if (args.length !== 1) {
1134
+ throwError(state, "YAML directive accepts exactly one argument");
1135
+ }
1136
+ match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
1137
+ if (match === null) {
1138
+ throwError(state, "ill-formed argument of the YAML directive");
1139
+ }
1140
+ major = parseInt(match[1], 10);
1141
+ minor = parseInt(match[2], 10);
1142
+ if (major !== 1) {
1143
+ throwError(state, "unacceptable YAML version of the document");
1144
+ }
1145
+ state.version = args[0];
1146
+ state.checkLineBreaks = minor < 2;
1147
+ if (minor !== 1 && minor !== 2) {
1148
+ throwWarning(state, "unsupported YAML version of the document");
1149
+ }
1150
+ },
1151
+ TAG: function handleTagDirective(state, name, args) {
1152
+ var handle, prefix;
1153
+ if (args.length !== 2) {
1154
+ throwError(state, "TAG directive accepts exactly two arguments");
1155
+ }
1156
+ handle = args[0];
1157
+ prefix = args[1];
1158
+ if (!PATTERN_TAG_HANDLE.test(handle)) {
1159
+ throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
1160
+ }
1161
+ if (_hasOwnProperty.call(state.tagMap, handle)) {
1162
+ throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
1163
+ }
1164
+ if (!PATTERN_TAG_URI.test(prefix)) {
1165
+ throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
1166
+ }
1167
+ try {
1168
+ prefix = decodeURIComponent(prefix);
1169
+ } catch (err) {
1170
+ throwError(state, "tag prefix is malformed: " + prefix);
1171
+ }
1172
+ state.tagMap[handle] = prefix;
1173
+ }
1174
+ };
1175
+ function captureSegment(state, start, end, checkJson) {
1176
+ var _position, _length2, _character, _result;
1177
+ if (start < end) {
1178
+ _result = state.input.slice(start, end);
1179
+ if (checkJson) {
1180
+ for (_position = 0, _length2 = _result.length; _position < _length2; _position += 1) {
1181
+ _character = _result.charCodeAt(_position);
1182
+ if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
1183
+ throwError(state, "expected valid JSON character");
1184
+ }
1185
+ }
1186
+ } else if (PATTERN_NON_PRINTABLE.test(_result)) {
1187
+ throwError(state, "the stream contains non-printable characters");
1188
+ }
1189
+ state.result += _result;
1190
+ }
1191
+ }
1192
+ function mergeMappings(state, destination, source, overridableKeys) {
1193
+ var sourceKeys, key, index, quantity;
1194
+ if (!common.isObject(source)) {
1195
+ throwError(state, "cannot merge mappings; the provided source object is unacceptable");
1196
+ }
1197
+ sourceKeys = Object.keys(source);
1198
+ for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
1199
+ key = sourceKeys[index];
1200
+ if (!_hasOwnProperty.call(destination, key)) {
1201
+ setProperty(destination, key, source[key]);
1202
+ overridableKeys[key] = true;
1203
+ }
1204
+ }
1205
+ }
1206
+ function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
1207
+ var index, quantity;
1208
+ if (Array.isArray(keyNode)) {
1209
+ keyNode = Array.prototype.slice.call(keyNode);
1210
+ for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
1211
+ if (Array.isArray(keyNode[index])) {
1212
+ throwError(state, "nested arrays are not supported inside keys");
1213
+ }
1214
+ if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
1215
+ keyNode[index] = "[object Object]";
1216
+ }
1217
+ }
1218
+ }
1219
+ if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
1220
+ keyNode = "[object Object]";
1221
+ }
1222
+ keyNode = String(keyNode);
1223
+ if (_result === null) {
1224
+ _result = {};
1225
+ }
1226
+ if (keyTag === "tag:yaml.org,2002:merge") {
1227
+ if (Array.isArray(valueNode)) {
1228
+ for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
1229
+ mergeMappings(state, _result, valueNode[index], overridableKeys);
1230
+ }
1231
+ } else {
1232
+ mergeMappings(state, _result, valueNode, overridableKeys);
1233
+ }
1234
+ } else {
1235
+ if (!state.json && !_hasOwnProperty.call(overridableKeys, keyNode) && _hasOwnProperty.call(_result, keyNode)) {
1236
+ state.line = startLine || state.line;
1237
+ state.lineStart = startLineStart || state.lineStart;
1238
+ state.position = startPos || state.position;
1239
+ throwError(state, "duplicated mapping key");
1240
+ }
1241
+ setProperty(_result, keyNode, valueNode);
1242
+ delete overridableKeys[keyNode];
1243
+ }
1244
+ return _result;
1245
+ }
1246
+ function readLineBreak(state) {
1247
+ var ch;
1248
+ ch = state.input.charCodeAt(state.position);
1249
+ if (ch === 10) {
1250
+ state.position++;
1251
+ } else if (ch === 13) {
1252
+ state.position++;
1253
+ if (state.input.charCodeAt(state.position) === 10) {
1254
+ state.position++;
1255
+ }
1256
+ } else {
1257
+ throwError(state, "a line break is expected");
1258
+ }
1259
+ state.line += 1;
1260
+ state.lineStart = state.position;
1261
+ state.firstTabInLine = -1;
1262
+ }
1263
+ function skipSeparationSpace(state, allowComments, checkIndent) {
1264
+ var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
1265
+ while (ch !== 0) {
1266
+ while (is_WHITE_SPACE(ch)) {
1267
+ if (ch === 9 && state.firstTabInLine === -1) {
1268
+ state.firstTabInLine = state.position;
1269
+ }
1270
+ ch = state.input.charCodeAt(++state.position);
1271
+ }
1272
+ if (allowComments && ch === 35) {
1273
+ do {
1274
+ ch = state.input.charCodeAt(++state.position);
1275
+ } while (ch !== 10 && ch !== 13 && ch !== 0);
1276
+ }
1277
+ if (is_EOL(ch)) {
1278
+ readLineBreak(state);
1279
+ ch = state.input.charCodeAt(state.position);
1280
+ lineBreaks++;
1281
+ state.lineIndent = 0;
1282
+ while (ch === 32) {
1283
+ state.lineIndent++;
1284
+ ch = state.input.charCodeAt(++state.position);
1285
+ }
1286
+ } else {
1287
+ break;
1288
+ }
1289
+ }
1290
+ if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
1291
+ throwWarning(state, "deficient indentation");
1292
+ }
1293
+ return lineBreaks;
1294
+ }
1295
+ function testDocumentSeparator(state) {
1296
+ var _position = state.position, ch;
1297
+ ch = state.input.charCodeAt(_position);
1298
+ if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
1299
+ _position += 3;
1300
+ ch = state.input.charCodeAt(_position);
1301
+ if (ch === 0 || is_WS_OR_EOL(ch)) {
1302
+ return true;
1303
+ }
1304
+ }
1305
+ return false;
1306
+ }
1307
+ function writeFoldedLines(state, count) {
1308
+ if (count === 1) {
1309
+ state.result += " ";
1310
+ } else if (count > 1) {
1311
+ state.result += common.repeat("\n", count - 1);
1312
+ }
1313
+ }
1314
+ function readPlainScalar(state, nodeIndent, withinFlowCollection) {
1315
+ var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
1316
+ ch = state.input.charCodeAt(state.position);
1317
+ if (is_WS_OR_EOL(ch) || is_FLOW_INDICATOR(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96) {
1318
+ return false;
1319
+ }
1320
+ if (ch === 63 || ch === 45) {
1321
+ following = state.input.charCodeAt(state.position + 1);
1322
+ if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
1323
+ return false;
1324
+ }
1325
+ }
1326
+ state.kind = "scalar";
1327
+ state.result = "";
1328
+ captureStart = captureEnd = state.position;
1329
+ hasPendingContent = false;
1330
+ while (ch !== 0) {
1331
+ if (ch === 58) {
1332
+ following = state.input.charCodeAt(state.position + 1);
1333
+ if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
1334
+ break;
1335
+ }
1336
+ } else if (ch === 35) {
1337
+ preceding = state.input.charCodeAt(state.position - 1);
1338
+ if (is_WS_OR_EOL(preceding)) {
1339
+ break;
1340
+ }
1341
+ } else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
1342
+ break;
1343
+ } else if (is_EOL(ch)) {
1344
+ _line = state.line;
1345
+ _lineStart = state.lineStart;
1346
+ _lineIndent = state.lineIndent;
1347
+ skipSeparationSpace(state, false, -1);
1348
+ if (state.lineIndent >= nodeIndent) {
1349
+ hasPendingContent = true;
1350
+ ch = state.input.charCodeAt(state.position);
1351
+ continue;
1352
+ } else {
1353
+ state.position = captureEnd;
1354
+ state.line = _line;
1355
+ state.lineStart = _lineStart;
1356
+ state.lineIndent = _lineIndent;
1357
+ break;
1358
+ }
1359
+ }
1360
+ if (hasPendingContent) {
1361
+ captureSegment(state, captureStart, captureEnd, false);
1362
+ writeFoldedLines(state, state.line - _line);
1363
+ captureStart = captureEnd = state.position;
1364
+ hasPendingContent = false;
1365
+ }
1366
+ if (!is_WHITE_SPACE(ch)) {
1367
+ captureEnd = state.position + 1;
1368
+ }
1369
+ ch = state.input.charCodeAt(++state.position);
1370
+ }
1371
+ captureSegment(state, captureStart, captureEnd, false);
1372
+ if (state.result) {
1373
+ return true;
1374
+ }
1375
+ state.kind = _kind;
1376
+ state.result = _result;
1377
+ return false;
1378
+ }
1379
+ function readSingleQuotedScalar(state, nodeIndent) {
1380
+ var ch, captureStart, captureEnd;
1381
+ ch = state.input.charCodeAt(state.position);
1382
+ if (ch !== 39) {
1383
+ return false;
1384
+ }
1385
+ state.kind = "scalar";
1386
+ state.result = "";
1387
+ state.position++;
1388
+ captureStart = captureEnd = state.position;
1389
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1390
+ if (ch === 39) {
1391
+ captureSegment(state, captureStart, state.position, true);
1392
+ ch = state.input.charCodeAt(++state.position);
1393
+ if (ch === 39) {
1394
+ captureStart = state.position;
1395
+ state.position++;
1396
+ captureEnd = state.position;
1397
+ } else {
1398
+ return true;
1399
+ }
1400
+ } else if (is_EOL(ch)) {
1401
+ captureSegment(state, captureStart, captureEnd, true);
1402
+ writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1403
+ captureStart = captureEnd = state.position;
1404
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1405
+ throwError(state, "unexpected end of the document within a single quoted scalar");
1406
+ } else {
1407
+ state.position++;
1408
+ captureEnd = state.position;
1409
+ }
1410
+ }
1411
+ throwError(state, "unexpected end of the stream within a single quoted scalar");
1412
+ }
1413
+ function readDoubleQuotedScalar(state, nodeIndent) {
1414
+ var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
1415
+ ch = state.input.charCodeAt(state.position);
1416
+ if (ch !== 34) {
1417
+ return false;
1418
+ }
1419
+ state.kind = "scalar";
1420
+ state.result = "";
1421
+ state.position++;
1422
+ captureStart = captureEnd = state.position;
1423
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1424
+ if (ch === 34) {
1425
+ captureSegment(state, captureStart, state.position, true);
1426
+ state.position++;
1427
+ return true;
1428
+ } else if (ch === 92) {
1429
+ captureSegment(state, captureStart, state.position, true);
1430
+ ch = state.input.charCodeAt(++state.position);
1431
+ if (is_EOL(ch)) {
1432
+ skipSeparationSpace(state, false, nodeIndent);
1433
+ } else if (ch < 256 && simpleEscapeCheck[ch]) {
1434
+ state.result += simpleEscapeMap[ch];
1435
+ state.position++;
1436
+ } else if ((tmp = escapedHexLen(ch)) > 0) {
1437
+ hexLength = tmp;
1438
+ hexResult = 0;
1439
+ for (; hexLength > 0; hexLength--) {
1440
+ ch = state.input.charCodeAt(++state.position);
1441
+ if ((tmp = fromHexCode(ch)) >= 0) {
1442
+ hexResult = (hexResult << 4) + tmp;
1443
+ } else {
1444
+ throwError(state, "expected hexadecimal character");
1445
+ }
1446
+ }
1447
+ state.result += charFromCodepoint(hexResult);
1448
+ state.position++;
1449
+ } else {
1450
+ throwError(state, "unknown escape sequence");
1451
+ }
1452
+ captureStart = captureEnd = state.position;
1453
+ } else if (is_EOL(ch)) {
1454
+ captureSegment(state, captureStart, captureEnd, true);
1455
+ writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1456
+ captureStart = captureEnd = state.position;
1457
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1458
+ throwError(state, "unexpected end of the document within a double quoted scalar");
1459
+ } else {
1460
+ state.position++;
1461
+ captureEnd = state.position;
1462
+ }
1463
+ }
1464
+ throwError(state, "unexpected end of the stream within a double quoted scalar");
1465
+ }
1466
+ function readFlowCollection(state, nodeIndent) {
1467
+ var readNext = true, _line, _lineStart, _pos, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = /* @__PURE__ */ Object.create(null), keyNode, keyTag, valueNode, ch;
1468
+ ch = state.input.charCodeAt(state.position);
1469
+ if (ch === 91) {
1470
+ terminator = 93;
1471
+ isMapping = false;
1472
+ _result = [];
1473
+ } else if (ch === 123) {
1474
+ terminator = 125;
1475
+ isMapping = true;
1476
+ _result = {};
1477
+ } else {
1478
+ return false;
1479
+ }
1480
+ if (state.anchor !== null) {
1481
+ state.anchorMap[state.anchor] = _result;
1482
+ }
1483
+ ch = state.input.charCodeAt(++state.position);
1484
+ while (ch !== 0) {
1485
+ skipSeparationSpace(state, true, nodeIndent);
1486
+ ch = state.input.charCodeAt(state.position);
1487
+ if (ch === terminator) {
1488
+ state.position++;
1489
+ state.tag = _tag;
1490
+ state.anchor = _anchor;
1491
+ state.kind = isMapping ? "mapping" : "sequence";
1492
+ state.result = _result;
1493
+ return true;
1494
+ } else if (!readNext) {
1495
+ throwError(state, "missed comma between flow collection entries");
1496
+ } else if (ch === 44) {
1497
+ throwError(state, "expected the node content, but found ','");
1498
+ }
1499
+ keyTag = keyNode = valueNode = null;
1500
+ isPair = isExplicitPair = false;
1501
+ if (ch === 63) {
1502
+ following = state.input.charCodeAt(state.position + 1);
1503
+ if (is_WS_OR_EOL(following)) {
1504
+ isPair = isExplicitPair = true;
1505
+ state.position++;
1506
+ skipSeparationSpace(state, true, nodeIndent);
1507
+ }
1508
+ }
1509
+ _line = state.line;
1510
+ _lineStart = state.lineStart;
1511
+ _pos = state.position;
1512
+ composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1513
+ keyTag = state.tag;
1514
+ keyNode = state.result;
1515
+ skipSeparationSpace(state, true, nodeIndent);
1516
+ ch = state.input.charCodeAt(state.position);
1517
+ if ((isExplicitPair || state.line === _line) && ch === 58) {
1518
+ isPair = true;
1519
+ ch = state.input.charCodeAt(++state.position);
1520
+ skipSeparationSpace(state, true, nodeIndent);
1521
+ composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1522
+ valueNode = state.result;
1523
+ }
1524
+ if (isMapping) {
1525
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
1526
+ } else if (isPair) {
1527
+ _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
1528
+ } else {
1529
+ _result.push(keyNode);
1530
+ }
1531
+ skipSeparationSpace(state, true, nodeIndent);
1532
+ ch = state.input.charCodeAt(state.position);
1533
+ if (ch === 44) {
1534
+ readNext = true;
1535
+ ch = state.input.charCodeAt(++state.position);
1536
+ } else {
1537
+ readNext = false;
1538
+ }
1539
+ }
1540
+ throwError(state, "unexpected end of the stream within a flow collection");
1541
+ }
1542
+ function readBlockScalar(state, nodeIndent) {
1543
+ var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
1544
+ ch = state.input.charCodeAt(state.position);
1545
+ if (ch === 124) {
1546
+ folding = false;
1547
+ } else if (ch === 62) {
1548
+ folding = true;
1549
+ } else {
1550
+ return false;
1551
+ }
1552
+ state.kind = "scalar";
1553
+ state.result = "";
1554
+ while (ch !== 0) {
1555
+ ch = state.input.charCodeAt(++state.position);
1556
+ if (ch === 43 || ch === 45) {
1557
+ if (CHOMPING_CLIP === chomping) {
1558
+ chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
1559
+ } else {
1560
+ throwError(state, "repeat of a chomping mode identifier");
1561
+ }
1562
+ } else if ((tmp = fromDecimalCode(ch)) >= 0) {
1563
+ if (tmp === 0) {
1564
+ throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
1565
+ } else if (!detectedIndent) {
1566
+ textIndent = nodeIndent + tmp - 1;
1567
+ detectedIndent = true;
1568
+ } else {
1569
+ throwError(state, "repeat of an indentation width identifier");
1570
+ }
1571
+ } else {
1572
+ break;
1573
+ }
1574
+ }
1575
+ if (is_WHITE_SPACE(ch)) {
1576
+ do {
1577
+ ch = state.input.charCodeAt(++state.position);
1578
+ } while (is_WHITE_SPACE(ch));
1579
+ if (ch === 35) {
1580
+ do {
1581
+ ch = state.input.charCodeAt(++state.position);
1582
+ } while (!is_EOL(ch) && ch !== 0);
1583
+ }
1584
+ }
1585
+ while (ch !== 0) {
1586
+ readLineBreak(state);
1587
+ state.lineIndent = 0;
1588
+ ch = state.input.charCodeAt(state.position);
1589
+ while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
1590
+ state.lineIndent++;
1591
+ ch = state.input.charCodeAt(++state.position);
1592
+ }
1593
+ if (!detectedIndent && state.lineIndent > textIndent) {
1594
+ textIndent = state.lineIndent;
1595
+ }
1596
+ if (is_EOL(ch)) {
1597
+ emptyLines++;
1598
+ continue;
1599
+ }
1600
+ if (state.lineIndent < textIndent) {
1601
+ if (chomping === CHOMPING_KEEP) {
1602
+ state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
1603
+ } else if (chomping === CHOMPING_CLIP) {
1604
+ if (didReadContent) {
1605
+ state.result += "\n";
1606
+ }
1607
+ }
1608
+ break;
1609
+ }
1610
+ if (folding) {
1611
+ if (is_WHITE_SPACE(ch)) {
1612
+ atMoreIndented = true;
1613
+ state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
1614
+ } else if (atMoreIndented) {
1615
+ atMoreIndented = false;
1616
+ state.result += common.repeat("\n", emptyLines + 1);
1617
+ } else if (emptyLines === 0) {
1618
+ if (didReadContent) {
1619
+ state.result += " ";
1620
+ }
1621
+ } else {
1622
+ state.result += common.repeat("\n", emptyLines);
1623
+ }
1624
+ } else {
1625
+ state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
1626
+ }
1627
+ didReadContent = true;
1628
+ detectedIndent = true;
1629
+ emptyLines = 0;
1630
+ captureStart = state.position;
1631
+ while (!is_EOL(ch) && ch !== 0) {
1632
+ ch = state.input.charCodeAt(++state.position);
1633
+ }
1634
+ captureSegment(state, captureStart, state.position, false);
1635
+ }
1636
+ return true;
1637
+ }
1638
+ function readBlockSequence(state, nodeIndent) {
1639
+ var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
1640
+ if (state.firstTabInLine !== -1) return false;
1641
+ if (state.anchor !== null) {
1642
+ state.anchorMap[state.anchor] = _result;
1643
+ }
1644
+ ch = state.input.charCodeAt(state.position);
1645
+ while (ch !== 0) {
1646
+ if (state.firstTabInLine !== -1) {
1647
+ state.position = state.firstTabInLine;
1648
+ throwError(state, "tab characters must not be used in indentation");
1649
+ }
1650
+ if (ch !== 45) {
1651
+ break;
1652
+ }
1653
+ following = state.input.charCodeAt(state.position + 1);
1654
+ if (!is_WS_OR_EOL(following)) {
1655
+ break;
1656
+ }
1657
+ detected = true;
1658
+ state.position++;
1659
+ if (skipSeparationSpace(state, true, -1)) {
1660
+ if (state.lineIndent <= nodeIndent) {
1661
+ _result.push(null);
1662
+ ch = state.input.charCodeAt(state.position);
1663
+ continue;
1664
+ }
1665
+ }
1666
+ _line = state.line;
1667
+ composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
1668
+ _result.push(state.result);
1669
+ skipSeparationSpace(state, true, -1);
1670
+ ch = state.input.charCodeAt(state.position);
1671
+ if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
1672
+ throwError(state, "bad indentation of a sequence entry");
1673
+ } else if (state.lineIndent < nodeIndent) {
1674
+ break;
1675
+ }
1676
+ }
1677
+ if (detected) {
1678
+ state.tag = _tag;
1679
+ state.anchor = _anchor;
1680
+ state.kind = "sequence";
1681
+ state.result = _result;
1682
+ return true;
1683
+ }
1684
+ return false;
1685
+ }
1686
+ function readBlockMapping(state, nodeIndent, flowIndent) {
1687
+ var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = /* @__PURE__ */ Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
1688
+ if (state.firstTabInLine !== -1) return false;
1689
+ if (state.anchor !== null) {
1690
+ state.anchorMap[state.anchor] = _result;
1691
+ }
1692
+ ch = state.input.charCodeAt(state.position);
1693
+ while (ch !== 0) {
1694
+ if (!atExplicitKey && state.firstTabInLine !== -1) {
1695
+ state.position = state.firstTabInLine;
1696
+ throwError(state, "tab characters must not be used in indentation");
1697
+ }
1698
+ following = state.input.charCodeAt(state.position + 1);
1699
+ _line = state.line;
1700
+ if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) {
1701
+ if (ch === 63) {
1702
+ if (atExplicitKey) {
1703
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
1704
+ keyTag = keyNode = valueNode = null;
1705
+ }
1706
+ detected = true;
1707
+ atExplicitKey = true;
1708
+ allowCompact = true;
1709
+ } else if (atExplicitKey) {
1710
+ atExplicitKey = false;
1711
+ allowCompact = true;
1712
+ } else {
1713
+ throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
1714
+ }
1715
+ state.position += 1;
1716
+ ch = following;
1717
+ } else {
1718
+ _keyLine = state.line;
1719
+ _keyLineStart = state.lineStart;
1720
+ _keyPos = state.position;
1721
+ if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
1722
+ break;
1723
+ }
1724
+ if (state.line === _line) {
1725
+ ch = state.input.charCodeAt(state.position);
1726
+ while (is_WHITE_SPACE(ch)) {
1727
+ ch = state.input.charCodeAt(++state.position);
1728
+ }
1729
+ if (ch === 58) {
1730
+ ch = state.input.charCodeAt(++state.position);
1731
+ if (!is_WS_OR_EOL(ch)) {
1732
+ throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
1733
+ }
1734
+ if (atExplicitKey) {
1735
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
1736
+ keyTag = keyNode = valueNode = null;
1737
+ }
1738
+ detected = true;
1739
+ atExplicitKey = false;
1740
+ allowCompact = false;
1741
+ keyTag = state.tag;
1742
+ keyNode = state.result;
1743
+ } else if (detected) {
1744
+ throwError(state, "can not read an implicit mapping pair; a colon is missed");
1745
+ } else {
1746
+ state.tag = _tag;
1747
+ state.anchor = _anchor;
1748
+ return true;
1749
+ }
1750
+ } else if (detected) {
1751
+ throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
1752
+ } else {
1753
+ state.tag = _tag;
1754
+ state.anchor = _anchor;
1755
+ return true;
1756
+ }
1757
+ }
1758
+ if (state.line === _line || state.lineIndent > nodeIndent) {
1759
+ if (atExplicitKey) {
1760
+ _keyLine = state.line;
1761
+ _keyLineStart = state.lineStart;
1762
+ _keyPos = state.position;
1763
+ }
1764
+ if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
1765
+ if (atExplicitKey) {
1766
+ keyNode = state.result;
1767
+ } else {
1768
+ valueNode = state.result;
1769
+ }
1770
+ }
1771
+ if (!atExplicitKey) {
1772
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
1773
+ keyTag = keyNode = valueNode = null;
1774
+ }
1775
+ skipSeparationSpace(state, true, -1);
1776
+ ch = state.input.charCodeAt(state.position);
1777
+ }
1778
+ if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
1779
+ throwError(state, "bad indentation of a mapping entry");
1780
+ } else if (state.lineIndent < nodeIndent) {
1781
+ break;
1782
+ }
1783
+ }
1784
+ if (atExplicitKey) {
1785
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
1786
+ }
1787
+ if (detected) {
1788
+ state.tag = _tag;
1789
+ state.anchor = _anchor;
1790
+ state.kind = "mapping";
1791
+ state.result = _result;
1792
+ }
1793
+ return detected;
1794
+ }
1795
+ function readTagProperty(state) {
1796
+ var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
1797
+ ch = state.input.charCodeAt(state.position);
1798
+ if (ch !== 33) return false;
1799
+ if (state.tag !== null) {
1800
+ throwError(state, "duplication of a tag property");
1801
+ }
1802
+ ch = state.input.charCodeAt(++state.position);
1803
+ if (ch === 60) {
1804
+ isVerbatim = true;
1805
+ ch = state.input.charCodeAt(++state.position);
1806
+ } else if (ch === 33) {
1807
+ isNamed = true;
1808
+ tagHandle = "!!";
1809
+ ch = state.input.charCodeAt(++state.position);
1810
+ } else {
1811
+ tagHandle = "!";
1812
+ }
1813
+ _position = state.position;
1814
+ if (isVerbatim) {
1815
+ do {
1816
+ ch = state.input.charCodeAt(++state.position);
1817
+ } while (ch !== 0 && ch !== 62);
1818
+ if (state.position < state.length) {
1819
+ tagName = state.input.slice(_position, state.position);
1820
+ ch = state.input.charCodeAt(++state.position);
1821
+ } else {
1822
+ throwError(state, "unexpected end of the stream within a verbatim tag");
1823
+ }
1824
+ } else {
1825
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
1826
+ if (ch === 33) {
1827
+ if (!isNamed) {
1828
+ tagHandle = state.input.slice(_position - 1, state.position + 1);
1829
+ if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
1830
+ throwError(state, "named tag handle cannot contain such characters");
1831
+ }
1832
+ isNamed = true;
1833
+ _position = state.position + 1;
1834
+ } else {
1835
+ throwError(state, "tag suffix cannot contain exclamation marks");
1836
+ }
1837
+ }
1838
+ ch = state.input.charCodeAt(++state.position);
1839
+ }
1840
+ tagName = state.input.slice(_position, state.position);
1841
+ if (PATTERN_FLOW_INDICATORS.test(tagName)) {
1842
+ throwError(state, "tag suffix cannot contain flow indicator characters");
1843
+ }
1844
+ }
1845
+ if (tagName && !PATTERN_TAG_URI.test(tagName)) {
1846
+ throwError(state, "tag name cannot contain such characters: " + tagName);
1847
+ }
1848
+ try {
1849
+ tagName = decodeURIComponent(tagName);
1850
+ } catch (err) {
1851
+ throwError(state, "tag name is malformed: " + tagName);
1852
+ }
1853
+ if (isVerbatim) {
1854
+ state.tag = tagName;
1855
+ } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
1856
+ state.tag = state.tagMap[tagHandle] + tagName;
1857
+ } else if (tagHandle === "!") {
1858
+ state.tag = "!" + tagName;
1859
+ } else if (tagHandle === "!!") {
1860
+ state.tag = "tag:yaml.org,2002:" + tagName;
1861
+ } else {
1862
+ throwError(state, 'undeclared tag handle "' + tagHandle + '"');
1863
+ }
1864
+ return true;
1865
+ }
1866
+ function readAnchorProperty(state) {
1867
+ var _position, ch;
1868
+ ch = state.input.charCodeAt(state.position);
1869
+ if (ch !== 38) return false;
1870
+ if (state.anchor !== null) {
1871
+ throwError(state, "duplication of an anchor property");
1872
+ }
1873
+ ch = state.input.charCodeAt(++state.position);
1874
+ _position = state.position;
1875
+ while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
1876
+ ch = state.input.charCodeAt(++state.position);
1877
+ }
1878
+ if (state.position === _position) {
1879
+ throwError(state, "name of an anchor node must contain at least one character");
1880
+ }
1881
+ state.anchor = state.input.slice(_position, state.position);
1882
+ return true;
1883
+ }
1884
+ function readAlias(state) {
1885
+ var _position, alias, ch;
1886
+ ch = state.input.charCodeAt(state.position);
1887
+ if (ch !== 42) return false;
1888
+ ch = state.input.charCodeAt(++state.position);
1889
+ _position = state.position;
1890
+ while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
1891
+ ch = state.input.charCodeAt(++state.position);
1892
+ }
1893
+ if (state.position === _position) {
1894
+ throwError(state, "name of an alias node must contain at least one character");
1895
+ }
1896
+ alias = state.input.slice(_position, state.position);
1897
+ if (!_hasOwnProperty.call(state.anchorMap, alias)) {
1898
+ throwError(state, 'unidentified alias "' + alias + '"');
1899
+ }
1900
+ state.result = state.anchorMap[alias];
1901
+ skipSeparationSpace(state, true, -1);
1902
+ return true;
1903
+ }
1904
+ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
1905
+ var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type, flowIndent, blockIndent;
1906
+ if (state.listener !== null) {
1907
+ state.listener("open", state);
1908
+ }
1909
+ state.tag = null;
1910
+ state.anchor = null;
1911
+ state.kind = null;
1912
+ state.result = null;
1913
+ allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
1914
+ if (allowToSeek) {
1915
+ if (skipSeparationSpace(state, true, -1)) {
1916
+ atNewLine = true;
1917
+ if (state.lineIndent > parentIndent) {
1918
+ indentStatus = 1;
1919
+ } else if (state.lineIndent === parentIndent) {
1920
+ indentStatus = 0;
1921
+ } else if (state.lineIndent < parentIndent) {
1922
+ indentStatus = -1;
1923
+ }
1924
+ }
1925
+ }
1926
+ if (indentStatus === 1) {
1927
+ while (readTagProperty(state) || readAnchorProperty(state)) {
1928
+ if (skipSeparationSpace(state, true, -1)) {
1929
+ atNewLine = true;
1930
+ allowBlockCollections = allowBlockStyles;
1931
+ if (state.lineIndent > parentIndent) {
1932
+ indentStatus = 1;
1933
+ } else if (state.lineIndent === parentIndent) {
1934
+ indentStatus = 0;
1935
+ } else if (state.lineIndent < parentIndent) {
1936
+ indentStatus = -1;
1937
+ }
1938
+ } else {
1939
+ allowBlockCollections = false;
1940
+ }
1941
+ }
1942
+ }
1943
+ if (allowBlockCollections) {
1944
+ allowBlockCollections = atNewLine || allowCompact;
1945
+ }
1946
+ if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
1947
+ if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
1948
+ flowIndent = parentIndent;
1949
+ } else {
1950
+ flowIndent = parentIndent + 1;
1951
+ }
1952
+ blockIndent = state.position - state.lineStart;
1953
+ if (indentStatus === 1) {
1954
+ if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
1955
+ hasContent = true;
1956
+ } else {
1957
+ if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
1958
+ hasContent = true;
1959
+ } else if (readAlias(state)) {
1960
+ hasContent = true;
1961
+ if (state.tag !== null || state.anchor !== null) {
1962
+ throwError(state, "alias node should not have any properties");
1963
+ }
1964
+ } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
1965
+ hasContent = true;
1966
+ if (state.tag === null) {
1967
+ state.tag = "?";
1968
+ }
1969
+ }
1970
+ if (state.anchor !== null) {
1971
+ state.anchorMap[state.anchor] = state.result;
1972
+ }
1973
+ }
1974
+ } else if (indentStatus === 0) {
1975
+ hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
1976
+ }
1977
+ }
1978
+ if (state.tag === null) {
1979
+ if (state.anchor !== null) {
1980
+ state.anchorMap[state.anchor] = state.result;
1981
+ }
1982
+ } else if (state.tag === "?") {
1983
+ if (state.result !== null && state.kind !== "scalar") {
1984
+ throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
1985
+ }
1986
+ for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
1987
+ type = state.implicitTypes[typeIndex];
1988
+ if (type.resolve(state.result)) {
1989
+ state.result = type.construct(state.result);
1990
+ state.tag = type.tag;
1991
+ if (state.anchor !== null) {
1992
+ state.anchorMap[state.anchor] = state.result;
1993
+ }
1994
+ break;
1995
+ }
1996
+ }
1997
+ } else if (state.tag !== "!") {
1998
+ if (_hasOwnProperty.call(state.typeMap[state.kind || "fallback"], state.tag)) {
1999
+ type = state.typeMap[state.kind || "fallback"][state.tag];
2000
+ } else {
2001
+ type = null;
2002
+ typeList = state.typeMap.multi[state.kind || "fallback"];
2003
+ for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) {
2004
+ if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
2005
+ type = typeList[typeIndex];
2006
+ break;
2007
+ }
2008
+ }
2009
+ }
2010
+ if (!type) {
2011
+ throwError(state, "unknown tag !<" + state.tag + ">");
2012
+ }
2013
+ if (state.result !== null && type.kind !== state.kind) {
2014
+ throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
2015
+ }
2016
+ if (!type.resolve(state.result, state.tag)) {
2017
+ throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
2018
+ } else {
2019
+ state.result = type.construct(state.result, state.tag);
2020
+ if (state.anchor !== null) {
2021
+ state.anchorMap[state.anchor] = state.result;
2022
+ }
2023
+ }
2024
+ }
2025
+ if (state.listener !== null) {
2026
+ state.listener("close", state);
2027
+ }
2028
+ return state.tag !== null || state.anchor !== null || hasContent;
2029
+ }
2030
+ function readDocument(state) {
2031
+ var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
2032
+ state.version = null;
2033
+ state.checkLineBreaks = state.legacy;
2034
+ state.tagMap = /* @__PURE__ */ Object.create(null);
2035
+ state.anchorMap = /* @__PURE__ */ Object.create(null);
2036
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
2037
+ skipSeparationSpace(state, true, -1);
2038
+ ch = state.input.charCodeAt(state.position);
2039
+ if (state.lineIndent > 0 || ch !== 37) {
2040
+ break;
2041
+ }
2042
+ hasDirectives = true;
2043
+ ch = state.input.charCodeAt(++state.position);
2044
+ _position = state.position;
2045
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2046
+ ch = state.input.charCodeAt(++state.position);
2047
+ }
2048
+ directiveName = state.input.slice(_position, state.position);
2049
+ directiveArgs = [];
2050
+ if (directiveName.length < 1) {
2051
+ throwError(state, "directive name must not be less than one character in length");
2052
+ }
2053
+ while (ch !== 0) {
2054
+ while (is_WHITE_SPACE(ch)) {
2055
+ ch = state.input.charCodeAt(++state.position);
2056
+ }
2057
+ if (ch === 35) {
2058
+ do {
2059
+ ch = state.input.charCodeAt(++state.position);
2060
+ } while (ch !== 0 && !is_EOL(ch));
2061
+ break;
2062
+ }
2063
+ if (is_EOL(ch)) break;
2064
+ _position = state.position;
2065
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2066
+ ch = state.input.charCodeAt(++state.position);
2067
+ }
2068
+ directiveArgs.push(state.input.slice(_position, state.position));
2069
+ }
2070
+ if (ch !== 0) readLineBreak(state);
2071
+ if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
2072
+ directiveHandlers[directiveName](state, directiveName, directiveArgs);
2073
+ } else {
2074
+ throwWarning(state, 'unknown document directive "' + directiveName + '"');
2075
+ }
2076
+ }
2077
+ skipSeparationSpace(state, true, -1);
2078
+ if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
2079
+ state.position += 3;
2080
+ skipSeparationSpace(state, true, -1);
2081
+ } else if (hasDirectives) {
2082
+ throwError(state, "directives end mark is expected");
2083
+ }
2084
+ composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
2085
+ skipSeparationSpace(state, true, -1);
2086
+ if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
2087
+ throwWarning(state, "non-ASCII line breaks are interpreted as content");
2088
+ }
2089
+ state.documents.push(state.result);
2090
+ if (state.position === state.lineStart && testDocumentSeparator(state)) {
2091
+ if (state.input.charCodeAt(state.position) === 46) {
2092
+ state.position += 3;
2093
+ skipSeparationSpace(state, true, -1);
2094
+ }
2095
+ return;
2096
+ }
2097
+ if (state.position < state.length - 1) {
2098
+ throwError(state, "end of the stream or a document separator is expected");
2099
+ } else {
2100
+ return;
2101
+ }
2102
+ }
2103
+ function loadDocuments(input, options) {
2104
+ input = String(input);
2105
+ options = options || {};
2106
+ if (input.length !== 0) {
2107
+ if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
2108
+ input += "\n";
2109
+ }
2110
+ if (input.charCodeAt(0) === 65279) {
2111
+ input = input.slice(1);
2112
+ }
2113
+ }
2114
+ var state = new State(input, options);
2115
+ var nullpos = input.indexOf("\0");
2116
+ if (nullpos !== -1) {
2117
+ state.position = nullpos;
2118
+ throwError(state, "null byte is not allowed in input");
2119
+ }
2120
+ state.input += "\0";
2121
+ while (state.input.charCodeAt(state.position) === 32) {
2122
+ state.lineIndent += 1;
2123
+ state.position += 1;
2124
+ }
2125
+ while (state.position < state.length - 1) {
2126
+ readDocument(state);
2127
+ }
2128
+ return state.documents;
2129
+ }
2130
+ function loadAll(input, iterator, options) {
2131
+ if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
2132
+ options = iterator;
2133
+ iterator = null;
2134
+ }
2135
+ var documents = loadDocuments(input, options);
2136
+ if (typeof iterator !== "function") {
2137
+ return documents;
2138
+ }
2139
+ for (var index = 0, length = documents.length; index < length; index += 1) {
2140
+ iterator(documents[index]);
2141
+ }
2142
+ }
2143
+ function load2(input, options) {
2144
+ var documents = loadDocuments(input, options);
2145
+ if (documents.length === 0) {
2146
+ return void 0;
2147
+ } else if (documents.length === 1) {
2148
+ return documents[0];
2149
+ }
2150
+ throw new YAMLException("expected a single document in the stream, but found more");
2151
+ }
2152
+ module2.exports.loadAll = loadAll;
2153
+ module2.exports.load = load2;
2154
+ }
2155
+ });
2156
+
2157
+ // node_modules/js-yaml/lib/dumper.js
2158
+ var require_dumper = __commonJS({
2159
+ "node_modules/js-yaml/lib/dumper.js"(exports2, module2) {
2160
+ "use strict";
2161
+ var common = require_common();
2162
+ var YAMLException = require_exception();
2163
+ var DEFAULT_SCHEMA = require_default();
2164
+ var _toString = Object.prototype.toString;
2165
+ var _hasOwnProperty = Object.prototype.hasOwnProperty;
2166
+ var CHAR_BOM = 65279;
2167
+ var CHAR_TAB = 9;
2168
+ var CHAR_LINE_FEED = 10;
2169
+ var CHAR_CARRIAGE_RETURN = 13;
2170
+ var CHAR_SPACE = 32;
2171
+ var CHAR_EXCLAMATION = 33;
2172
+ var CHAR_DOUBLE_QUOTE = 34;
2173
+ var CHAR_SHARP = 35;
2174
+ var CHAR_PERCENT = 37;
2175
+ var CHAR_AMPERSAND = 38;
2176
+ var CHAR_SINGLE_QUOTE = 39;
2177
+ var CHAR_ASTERISK = 42;
2178
+ var CHAR_COMMA = 44;
2179
+ var CHAR_MINUS = 45;
2180
+ var CHAR_COLON = 58;
2181
+ var CHAR_EQUALS = 61;
2182
+ var CHAR_GREATER_THAN = 62;
2183
+ var CHAR_QUESTION = 63;
2184
+ var CHAR_COMMERCIAL_AT = 64;
2185
+ var CHAR_LEFT_SQUARE_BRACKET = 91;
2186
+ var CHAR_RIGHT_SQUARE_BRACKET = 93;
2187
+ var CHAR_GRAVE_ACCENT = 96;
2188
+ var CHAR_LEFT_CURLY_BRACKET = 123;
2189
+ var CHAR_VERTICAL_LINE = 124;
2190
+ var CHAR_RIGHT_CURLY_BRACKET = 125;
2191
+ var ESCAPE_SEQUENCES = {};
2192
+ ESCAPE_SEQUENCES[0] = "\\0";
2193
+ ESCAPE_SEQUENCES[7] = "\\a";
2194
+ ESCAPE_SEQUENCES[8] = "\\b";
2195
+ ESCAPE_SEQUENCES[9] = "\\t";
2196
+ ESCAPE_SEQUENCES[10] = "\\n";
2197
+ ESCAPE_SEQUENCES[11] = "\\v";
2198
+ ESCAPE_SEQUENCES[12] = "\\f";
2199
+ ESCAPE_SEQUENCES[13] = "\\r";
2200
+ ESCAPE_SEQUENCES[27] = "\\e";
2201
+ ESCAPE_SEQUENCES[34] = '\\"';
2202
+ ESCAPE_SEQUENCES[92] = "\\\\";
2203
+ ESCAPE_SEQUENCES[133] = "\\N";
2204
+ ESCAPE_SEQUENCES[160] = "\\_";
2205
+ ESCAPE_SEQUENCES[8232] = "\\L";
2206
+ ESCAPE_SEQUENCES[8233] = "\\P";
2207
+ var DEPRECATED_BOOLEANS_SYNTAX = [
2208
+ "y",
2209
+ "Y",
2210
+ "yes",
2211
+ "Yes",
2212
+ "YES",
2213
+ "on",
2214
+ "On",
2215
+ "ON",
2216
+ "n",
2217
+ "N",
2218
+ "no",
2219
+ "No",
2220
+ "NO",
2221
+ "off",
2222
+ "Off",
2223
+ "OFF"
2224
+ ];
2225
+ var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
2226
+ function compileStyleMap(schema, map2) {
2227
+ var result, keys, index, length, tag, style, type;
2228
+ if (map2 === null) return {};
2229
+ result = {};
2230
+ keys = Object.keys(map2);
2231
+ for (index = 0, length = keys.length; index < length; index += 1) {
2232
+ tag = keys[index];
2233
+ style = String(map2[tag]);
2234
+ if (tag.slice(0, 2) === "!!") {
2235
+ tag = "tag:yaml.org,2002:" + tag.slice(2);
2236
+ }
2237
+ type = schema.compiledTypeMap["fallback"][tag];
2238
+ if (type && _hasOwnProperty.call(type.styleAliases, style)) {
2239
+ style = type.styleAliases[style];
2240
+ }
2241
+ result[tag] = style;
2242
+ }
2243
+ return result;
2244
+ }
2245
+ function encodeHex(character) {
2246
+ var string4, handle, length;
2247
+ string4 = character.toString(16).toUpperCase();
2248
+ if (character <= 255) {
2249
+ handle = "x";
2250
+ length = 2;
2251
+ } else if (character <= 65535) {
2252
+ handle = "u";
2253
+ length = 4;
2254
+ } else if (character <= 4294967295) {
2255
+ handle = "U";
2256
+ length = 8;
2257
+ } else {
2258
+ throw new YAMLException("code point within a string may not be greater than 0xFFFFFFFF");
2259
+ }
2260
+ return "\\" + handle + common.repeat("0", length - string4.length) + string4;
2261
+ }
2262
+ var QUOTING_TYPE_SINGLE = 1;
2263
+ var QUOTING_TYPE_DOUBLE = 2;
2264
+ function State(options) {
2265
+ this.schema = options["schema"] || DEFAULT_SCHEMA;
2266
+ this.indent = Math.max(1, options["indent"] || 2);
2267
+ this.noArrayIndent = options["noArrayIndent"] || false;
2268
+ this.skipInvalid = options["skipInvalid"] || false;
2269
+ this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
2270
+ this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
2271
+ this.sortKeys = options["sortKeys"] || false;
2272
+ this.lineWidth = options["lineWidth"] || 80;
2273
+ this.noRefs = options["noRefs"] || false;
2274
+ this.noCompatMode = options["noCompatMode"] || false;
2275
+ this.condenseFlow = options["condenseFlow"] || false;
2276
+ this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
2277
+ this.forceQuotes = options["forceQuotes"] || false;
2278
+ this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
2279
+ this.implicitTypes = this.schema.compiledImplicit;
2280
+ this.explicitTypes = this.schema.compiledExplicit;
2281
+ this.tag = null;
2282
+ this.result = "";
2283
+ this.duplicates = [];
2284
+ this.usedDuplicates = null;
2285
+ }
2286
+ function indentString(string4, spaces) {
2287
+ var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string4.length;
2288
+ while (position < length) {
2289
+ next = string4.indexOf("\n", position);
2290
+ if (next === -1) {
2291
+ line = string4.slice(position);
2292
+ position = length;
2293
+ } else {
2294
+ line = string4.slice(position, next + 1);
2295
+ position = next + 1;
2296
+ }
2297
+ if (line.length && line !== "\n") result += ind;
2298
+ result += line;
2299
+ }
2300
+ return result;
2301
+ }
2302
+ function generateNextLine(state, level) {
2303
+ return "\n" + common.repeat(" ", state.indent * level);
2304
+ }
2305
+ function testImplicitResolving(state, str) {
2306
+ var index, length, type;
2307
+ for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
2308
+ type = state.implicitTypes[index];
2309
+ if (type.resolve(str)) {
2310
+ return true;
2311
+ }
2312
+ }
2313
+ return false;
2314
+ }
2315
+ function isWhitespace(c) {
2316
+ return c === CHAR_SPACE || c === CHAR_TAB;
2317
+ }
2318
+ function isPrintable(c) {
2319
+ return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== CHAR_BOM || 65536 <= c && c <= 1114111;
2320
+ }
2321
+ function isNsCharOrWhitespace(c) {
2322
+ return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
2323
+ }
2324
+ function isPlainSafe(c, prev, inblock) {
2325
+ var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
2326
+ var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
2327
+ return (
2328
+ // ns-plain-safe
2329
+ (inblock ? (
2330
+ // c = flow-in
2331
+ cIsNsCharOrWhitespace
2332
+ ) : cIsNsCharOrWhitespace && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET) && c !== CHAR_SHARP && !(prev === CHAR_COLON && !cIsNsChar) || isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP || prev === CHAR_COLON && cIsNsChar
2333
+ );
2334
+ }
2335
+ function isPlainSafeFirst(c) {
2336
+ return isPrintable(c) && c !== CHAR_BOM && !isWhitespace(c) && c !== CHAR_MINUS && c !== CHAR_QUESTION && c !== CHAR_COLON && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET && c !== CHAR_SHARP && c !== CHAR_AMPERSAND && c !== CHAR_ASTERISK && c !== CHAR_EXCLAMATION && c !== CHAR_VERTICAL_LINE && c !== CHAR_EQUALS && c !== CHAR_GREATER_THAN && c !== CHAR_SINGLE_QUOTE && c !== CHAR_DOUBLE_QUOTE && c !== CHAR_PERCENT && c !== CHAR_COMMERCIAL_AT && c !== CHAR_GRAVE_ACCENT;
2337
+ }
2338
+ function isPlainSafeLast(c) {
2339
+ return !isWhitespace(c) && c !== CHAR_COLON;
2340
+ }
2341
+ function codePointAt(string4, pos) {
2342
+ var first = string4.charCodeAt(pos), second;
2343
+ if (first >= 55296 && first <= 56319 && pos + 1 < string4.length) {
2344
+ second = string4.charCodeAt(pos + 1);
2345
+ if (second >= 56320 && second <= 57343) {
2346
+ return (first - 55296) * 1024 + second - 56320 + 65536;
2347
+ }
2348
+ }
2349
+ return first;
2350
+ }
2351
+ function needIndentIndicator(string4) {
2352
+ var leadingSpaceRe = /^\n* /;
2353
+ return leadingSpaceRe.test(string4);
2354
+ }
2355
+ var STYLE_PLAIN = 1;
2356
+ var STYLE_SINGLE = 2;
2357
+ var STYLE_LITERAL = 3;
2358
+ var STYLE_FOLDED = 4;
2359
+ var STYLE_DOUBLE = 5;
2360
+ function chooseScalarStyle(string4, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
2361
+ var i;
2362
+ var char = 0;
2363
+ var prevChar = null;
2364
+ var hasLineBreak = false;
2365
+ var hasFoldableLine = false;
2366
+ var shouldTrackWidth = lineWidth !== -1;
2367
+ var previousLineBreak = -1;
2368
+ var plain = isPlainSafeFirst(codePointAt(string4, 0)) && isPlainSafeLast(codePointAt(string4, string4.length - 1));
2369
+ if (singleLineOnly || forceQuotes) {
2370
+ for (i = 0; i < string4.length; char >= 65536 ? i += 2 : i++) {
2371
+ char = codePointAt(string4, i);
2372
+ if (!isPrintable(char)) {
2373
+ return STYLE_DOUBLE;
2374
+ }
2375
+ plain = plain && isPlainSafe(char, prevChar, inblock);
2376
+ prevChar = char;
2377
+ }
2378
+ } else {
2379
+ for (i = 0; i < string4.length; char >= 65536 ? i += 2 : i++) {
2380
+ char = codePointAt(string4, i);
2381
+ if (char === CHAR_LINE_FEED) {
2382
+ hasLineBreak = true;
2383
+ if (shouldTrackWidth) {
2384
+ hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented.
2385
+ i - previousLineBreak - 1 > lineWidth && string4[previousLineBreak + 1] !== " ";
2386
+ previousLineBreak = i;
2387
+ }
2388
+ } else if (!isPrintable(char)) {
2389
+ return STYLE_DOUBLE;
2390
+ }
2391
+ plain = plain && isPlainSafe(char, prevChar, inblock);
2392
+ prevChar = char;
2393
+ }
2394
+ hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && string4[previousLineBreak + 1] !== " ");
2395
+ }
2396
+ if (!hasLineBreak && !hasFoldableLine) {
2397
+ if (plain && !forceQuotes && !testAmbiguousType(string4)) {
2398
+ return STYLE_PLAIN;
2399
+ }
2400
+ return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
2401
+ }
2402
+ if (indentPerLevel > 9 && needIndentIndicator(string4)) {
2403
+ return STYLE_DOUBLE;
2404
+ }
2405
+ if (!forceQuotes) {
2406
+ return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
2407
+ }
2408
+ return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
2409
+ }
2410
+ function writeScalar(state, string4, level, iskey, inblock) {
2411
+ state.dump = (function() {
2412
+ if (string4.length === 0) {
2413
+ return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
2414
+ }
2415
+ if (!state.noCompatMode) {
2416
+ if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string4) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string4)) {
2417
+ return state.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string4 + '"' : "'" + string4 + "'";
2418
+ }
2419
+ }
2420
+ var indent = state.indent * Math.max(1, level);
2421
+ var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
2422
+ var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
2423
+ function testAmbiguity(string5) {
2424
+ return testImplicitResolving(state, string5);
2425
+ }
2426
+ switch (chooseScalarStyle(
2427
+ string4,
2428
+ singleLineOnly,
2429
+ state.indent,
2430
+ lineWidth,
2431
+ testAmbiguity,
2432
+ state.quotingType,
2433
+ state.forceQuotes && !iskey,
2434
+ inblock
2435
+ )) {
2436
+ case STYLE_PLAIN:
2437
+ return string4;
2438
+ case STYLE_SINGLE:
2439
+ return "'" + string4.replace(/'/g, "''") + "'";
2440
+ case STYLE_LITERAL:
2441
+ return "|" + blockHeader(string4, state.indent) + dropEndingNewline(indentString(string4, indent));
2442
+ case STYLE_FOLDED:
2443
+ return ">" + blockHeader(string4, state.indent) + dropEndingNewline(indentString(foldString(string4, lineWidth), indent));
2444
+ case STYLE_DOUBLE:
2445
+ return '"' + escapeString(string4, lineWidth) + '"';
2446
+ default:
2447
+ throw new YAMLException("impossible error: invalid scalar style");
2448
+ }
2449
+ })();
2450
+ }
2451
+ function blockHeader(string4, indentPerLevel) {
2452
+ var indentIndicator = needIndentIndicator(string4) ? String(indentPerLevel) : "";
2453
+ var clip = string4[string4.length - 1] === "\n";
2454
+ var keep = clip && (string4[string4.length - 2] === "\n" || string4 === "\n");
2455
+ var chomp = keep ? "+" : clip ? "" : "-";
2456
+ return indentIndicator + chomp + "\n";
2457
+ }
2458
+ function dropEndingNewline(string4) {
2459
+ return string4[string4.length - 1] === "\n" ? string4.slice(0, -1) : string4;
2460
+ }
2461
+ function foldString(string4, width) {
2462
+ var lineRe = /(\n+)([^\n]*)/g;
2463
+ var result = (function() {
2464
+ var nextLF = string4.indexOf("\n");
2465
+ nextLF = nextLF !== -1 ? nextLF : string4.length;
2466
+ lineRe.lastIndex = nextLF;
2467
+ return foldLine(string4.slice(0, nextLF), width);
2468
+ })();
2469
+ var prevMoreIndented = string4[0] === "\n" || string4[0] === " ";
2470
+ var moreIndented;
2471
+ var match;
2472
+ while (match = lineRe.exec(string4)) {
2473
+ var prefix = match[1], line = match[2];
2474
+ moreIndented = line[0] === " ";
2475
+ result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
2476
+ prevMoreIndented = moreIndented;
2477
+ }
2478
+ return result;
2479
+ }
2480
+ function foldLine(line, width) {
2481
+ if (line === "" || line[0] === " ") return line;
2482
+ var breakRe = / [^ ]/g;
2483
+ var match;
2484
+ var start = 0, end, curr = 0, next = 0;
2485
+ var result = "";
2486
+ while (match = breakRe.exec(line)) {
2487
+ next = match.index;
2488
+ if (next - start > width) {
2489
+ end = curr > start ? curr : next;
2490
+ result += "\n" + line.slice(start, end);
2491
+ start = end + 1;
2492
+ }
2493
+ curr = next;
2494
+ }
2495
+ result += "\n";
2496
+ if (line.length - start > width && curr > start) {
2497
+ result += line.slice(start, curr) + "\n" + line.slice(curr + 1);
2498
+ } else {
2499
+ result += line.slice(start);
2500
+ }
2501
+ return result.slice(1);
2502
+ }
2503
+ function escapeString(string4) {
2504
+ var result = "";
2505
+ var char = 0;
2506
+ var escapeSeq;
2507
+ for (var i = 0; i < string4.length; char >= 65536 ? i += 2 : i++) {
2508
+ char = codePointAt(string4, i);
2509
+ escapeSeq = ESCAPE_SEQUENCES[char];
2510
+ if (!escapeSeq && isPrintable(char)) {
2511
+ result += string4[i];
2512
+ if (char >= 65536) result += string4[i + 1];
2513
+ } else {
2514
+ result += escapeSeq || encodeHex(char);
2515
+ }
2516
+ }
2517
+ return result;
2518
+ }
2519
+ function writeFlowSequence(state, level, object2) {
2520
+ var _result = "", _tag = state.tag, index, length, value;
2521
+ for (index = 0, length = object2.length; index < length; index += 1) {
2522
+ value = object2[index];
2523
+ if (state.replacer) {
2524
+ value = state.replacer.call(object2, String(index), value);
2525
+ }
2526
+ if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
2527
+ if (_result !== "") _result += "," + (!state.condenseFlow ? " " : "");
2528
+ _result += state.dump;
2529
+ }
2530
+ }
2531
+ state.tag = _tag;
2532
+ state.dump = "[" + _result + "]";
2533
+ }
2534
+ function writeBlockSequence(state, level, object2, compact) {
2535
+ var _result = "", _tag = state.tag, index, length, value;
2536
+ for (index = 0, length = object2.length; index < length; index += 1) {
2537
+ value = object2[index];
2538
+ if (state.replacer) {
2539
+ value = state.replacer.call(object2, String(index), value);
2540
+ }
2541
+ if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
2542
+ if (!compact || _result !== "") {
2543
+ _result += generateNextLine(state, level);
2544
+ }
2545
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
2546
+ _result += "-";
2547
+ } else {
2548
+ _result += "- ";
2549
+ }
2550
+ _result += state.dump;
2551
+ }
2552
+ }
2553
+ state.tag = _tag;
2554
+ state.dump = _result || "[]";
2555
+ }
2556
+ function writeFlowMapping(state, level, object2) {
2557
+ var _result = "", _tag = state.tag, objectKeyList = Object.keys(object2), index, length, objectKey, objectValue, pairBuffer;
2558
+ for (index = 0, length = objectKeyList.length; index < length; index += 1) {
2559
+ pairBuffer = "";
2560
+ if (_result !== "") pairBuffer += ", ";
2561
+ if (state.condenseFlow) pairBuffer += '"';
2562
+ objectKey = objectKeyList[index];
2563
+ objectValue = object2[objectKey];
2564
+ if (state.replacer) {
2565
+ objectValue = state.replacer.call(object2, objectKey, objectValue);
2566
+ }
2567
+ if (!writeNode(state, level, objectKey, false, false)) {
2568
+ continue;
2569
+ }
2570
+ if (state.dump.length > 1024) pairBuffer += "? ";
2571
+ pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
2572
+ if (!writeNode(state, level, objectValue, false, false)) {
2573
+ continue;
2574
+ }
2575
+ pairBuffer += state.dump;
2576
+ _result += pairBuffer;
2577
+ }
2578
+ state.tag = _tag;
2579
+ state.dump = "{" + _result + "}";
2580
+ }
2581
+ function writeBlockMapping(state, level, object2, compact) {
2582
+ var _result = "", _tag = state.tag, objectKeyList = Object.keys(object2), index, length, objectKey, objectValue, explicitPair, pairBuffer;
2583
+ if (state.sortKeys === true) {
2584
+ objectKeyList.sort();
2585
+ } else if (typeof state.sortKeys === "function") {
2586
+ objectKeyList.sort(state.sortKeys);
2587
+ } else if (state.sortKeys) {
2588
+ throw new YAMLException("sortKeys must be a boolean or a function");
2589
+ }
2590
+ for (index = 0, length = objectKeyList.length; index < length; index += 1) {
2591
+ pairBuffer = "";
2592
+ if (!compact || _result !== "") {
2593
+ pairBuffer += generateNextLine(state, level);
2594
+ }
2595
+ objectKey = objectKeyList[index];
2596
+ objectValue = object2[objectKey];
2597
+ if (state.replacer) {
2598
+ objectValue = state.replacer.call(object2, objectKey, objectValue);
2599
+ }
2600
+ if (!writeNode(state, level + 1, objectKey, true, true, true)) {
2601
+ continue;
2602
+ }
2603
+ explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
2604
+ if (explicitPair) {
2605
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
2606
+ pairBuffer += "?";
2607
+ } else {
2608
+ pairBuffer += "? ";
2609
+ }
2610
+ }
2611
+ pairBuffer += state.dump;
2612
+ if (explicitPair) {
2613
+ pairBuffer += generateNextLine(state, level);
2614
+ }
2615
+ if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
2616
+ continue;
2617
+ }
2618
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
2619
+ pairBuffer += ":";
2620
+ } else {
2621
+ pairBuffer += ": ";
2622
+ }
2623
+ pairBuffer += state.dump;
2624
+ _result += pairBuffer;
2625
+ }
2626
+ state.tag = _tag;
2627
+ state.dump = _result || "{}";
2628
+ }
2629
+ function detectType(state, object2, explicit) {
2630
+ var _result, typeList, index, length, type, style;
2631
+ typeList = explicit ? state.explicitTypes : state.implicitTypes;
2632
+ for (index = 0, length = typeList.length; index < length; index += 1) {
2633
+ type = typeList[index];
2634
+ if ((type.instanceOf || type.predicate) && (!type.instanceOf || typeof object2 === "object" && object2 instanceof type.instanceOf) && (!type.predicate || type.predicate(object2))) {
2635
+ if (explicit) {
2636
+ if (type.multi && type.representName) {
2637
+ state.tag = type.representName(object2);
2638
+ } else {
2639
+ state.tag = type.tag;
2640
+ }
2641
+ } else {
2642
+ state.tag = "?";
2643
+ }
2644
+ if (type.represent) {
2645
+ style = state.styleMap[type.tag] || type.defaultStyle;
2646
+ if (_toString.call(type.represent) === "[object Function]") {
2647
+ _result = type.represent(object2, style);
2648
+ } else if (_hasOwnProperty.call(type.represent, style)) {
2649
+ _result = type.represent[style](object2, style);
2650
+ } else {
2651
+ throw new YAMLException("!<" + type.tag + '> tag resolver accepts not "' + style + '" style');
2652
+ }
2653
+ state.dump = _result;
2654
+ }
2655
+ return true;
2656
+ }
2657
+ }
2658
+ return false;
2659
+ }
2660
+ function writeNode(state, level, object2, block, compact, iskey, isblockseq) {
2661
+ state.tag = null;
2662
+ state.dump = object2;
2663
+ if (!detectType(state, object2, false)) {
2664
+ detectType(state, object2, true);
2665
+ }
2666
+ var type = _toString.call(state.dump);
2667
+ var inblock = block;
2668
+ var tagStr;
2669
+ if (block) {
2670
+ block = state.flowLevel < 0 || state.flowLevel > level;
2671
+ }
2672
+ var objectOrArray = type === "[object Object]" || type === "[object Array]", duplicateIndex, duplicate;
2673
+ if (objectOrArray) {
2674
+ duplicateIndex = state.duplicates.indexOf(object2);
2675
+ duplicate = duplicateIndex !== -1;
2676
+ }
2677
+ if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
2678
+ compact = false;
2679
+ }
2680
+ if (duplicate && state.usedDuplicates[duplicateIndex]) {
2681
+ state.dump = "*ref_" + duplicateIndex;
2682
+ } else {
2683
+ if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
2684
+ state.usedDuplicates[duplicateIndex] = true;
2685
+ }
2686
+ if (type === "[object Object]") {
2687
+ if (block && Object.keys(state.dump).length !== 0) {
2688
+ writeBlockMapping(state, level, state.dump, compact);
2689
+ if (duplicate) {
2690
+ state.dump = "&ref_" + duplicateIndex + state.dump;
2691
+ }
2692
+ } else {
2693
+ writeFlowMapping(state, level, state.dump);
2694
+ if (duplicate) {
2695
+ state.dump = "&ref_" + duplicateIndex + " " + state.dump;
2696
+ }
2697
+ }
2698
+ } else if (type === "[object Array]") {
2699
+ if (block && state.dump.length !== 0) {
2700
+ if (state.noArrayIndent && !isblockseq && level > 0) {
2701
+ writeBlockSequence(state, level - 1, state.dump, compact);
2702
+ } else {
2703
+ writeBlockSequence(state, level, state.dump, compact);
2704
+ }
2705
+ if (duplicate) {
2706
+ state.dump = "&ref_" + duplicateIndex + state.dump;
2707
+ }
2708
+ } else {
2709
+ writeFlowSequence(state, level, state.dump);
2710
+ if (duplicate) {
2711
+ state.dump = "&ref_" + duplicateIndex + " " + state.dump;
2712
+ }
2713
+ }
2714
+ } else if (type === "[object String]") {
2715
+ if (state.tag !== "?") {
2716
+ writeScalar(state, state.dump, level, iskey, inblock);
2717
+ }
2718
+ } else if (type === "[object Undefined]") {
2719
+ return false;
2720
+ } else {
2721
+ if (state.skipInvalid) return false;
2722
+ throw new YAMLException("unacceptable kind of an object to dump " + type);
2723
+ }
2724
+ if (state.tag !== null && state.tag !== "?") {
2725
+ tagStr = encodeURI(
2726
+ state.tag[0] === "!" ? state.tag.slice(1) : state.tag
2727
+ ).replace(/!/g, "%21");
2728
+ if (state.tag[0] === "!") {
2729
+ tagStr = "!" + tagStr;
2730
+ } else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") {
2731
+ tagStr = "!!" + tagStr.slice(18);
2732
+ } else {
2733
+ tagStr = "!<" + tagStr + ">";
2734
+ }
2735
+ state.dump = tagStr + " " + state.dump;
2736
+ }
2737
+ }
2738
+ return true;
2739
+ }
2740
+ function getDuplicateReferences(object2, state) {
2741
+ var objects = [], duplicatesIndexes = [], index, length;
2742
+ inspectNode(object2, objects, duplicatesIndexes);
2743
+ for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
2744
+ state.duplicates.push(objects[duplicatesIndexes[index]]);
2745
+ }
2746
+ state.usedDuplicates = new Array(length);
2747
+ }
2748
+ function inspectNode(object2, objects, duplicatesIndexes) {
2749
+ var objectKeyList, index, length;
2750
+ if (object2 !== null && typeof object2 === "object") {
2751
+ index = objects.indexOf(object2);
2752
+ if (index !== -1) {
2753
+ if (duplicatesIndexes.indexOf(index) === -1) {
2754
+ duplicatesIndexes.push(index);
2755
+ }
2756
+ } else {
2757
+ objects.push(object2);
2758
+ if (Array.isArray(object2)) {
2759
+ for (index = 0, length = object2.length; index < length; index += 1) {
2760
+ inspectNode(object2[index], objects, duplicatesIndexes);
2761
+ }
2762
+ } else {
2763
+ objectKeyList = Object.keys(object2);
2764
+ for (index = 0, length = objectKeyList.length; index < length; index += 1) {
2765
+ inspectNode(object2[objectKeyList[index]], objects, duplicatesIndexes);
2766
+ }
2767
+ }
2768
+ }
2769
+ }
2770
+ }
2771
+ function dump(input, options) {
2772
+ options = options || {};
2773
+ var state = new State(options);
2774
+ if (!state.noRefs) getDuplicateReferences(input, state);
2775
+ var value = input;
2776
+ if (state.replacer) {
2777
+ value = state.replacer.call({ "": value }, "", value);
2778
+ }
2779
+ if (writeNode(state, 0, value, true, true)) return state.dump + "\n";
2780
+ return "";
2781
+ }
2782
+ module2.exports.dump = dump;
2783
+ }
2784
+ });
2785
+
2786
+ // node_modules/js-yaml/index.js
2787
+ var require_js_yaml = __commonJS({
2788
+ "node_modules/js-yaml/index.js"(exports2, module2) {
2789
+ "use strict";
2790
+ var loader = require_loader();
2791
+ var dumper = require_dumper();
2792
+ function renamed(from, to) {
2793
+ return function() {
2794
+ throw new Error("Function yaml." + from + " is removed in js-yaml 4. Use yaml." + to + " instead, which is now safe by default.");
2795
+ };
2796
+ }
2797
+ module2.exports.Type = require_type();
2798
+ module2.exports.Schema = require_schema();
2799
+ module2.exports.FAILSAFE_SCHEMA = require_failsafe();
2800
+ module2.exports.JSON_SCHEMA = require_json();
2801
+ module2.exports.CORE_SCHEMA = require_core();
2802
+ module2.exports.DEFAULT_SCHEMA = require_default();
2803
+ module2.exports.load = loader.load;
2804
+ module2.exports.loadAll = loader.loadAll;
2805
+ module2.exports.dump = dumper.dump;
2806
+ module2.exports.YAMLException = require_exception();
2807
+ module2.exports.types = {
2808
+ binary: require_binary(),
2809
+ float: require_float(),
2810
+ map: require_map(),
2811
+ null: require_null(),
2812
+ pairs: require_pairs(),
2813
+ set: require_set(),
2814
+ timestamp: require_timestamp(),
2815
+ bool: require_bool(),
2816
+ int: require_int(),
2817
+ merge: require_merge(),
2818
+ omap: require_omap(),
2819
+ seq: require_seq(),
2820
+ str: require_str()
2821
+ };
2822
+ module2.exports.safeLoad = renamed("safeLoad", "load");
2823
+ module2.exports.safeLoadAll = renamed("safeLoadAll", "loadAll");
2824
+ module2.exports.safeDump = renamed("safeDump", "dump");
2825
+ }
2826
+ });
2827
+
32
2828
  // node_modules/chardet/lib/fs/node.js
33
2829
  var require_node = __commonJS({
34
2830
  "node_modules/chardet/lib/fs/node.js"(exports2, module2) {
@@ -5607,10 +8403,10 @@ var require_lib = __commonJS({
5607
8403
  exports2.analyse = analyse;
5608
8404
  var detectFile = (filepath, opts = {}) => new Promise((resolve, reject) => {
5609
8405
  let fd;
5610
- const fs14 = (0, node_1.default)();
8406
+ const fs23 = (0, node_1.default)();
5611
8407
  const handler = (err, buffer) => {
5612
8408
  if (fd) {
5613
- fs14.closeSync(fd);
8409
+ fs23.closeSync(fd);
5614
8410
  }
5615
8411
  if (err) {
5616
8412
  reject(err);
@@ -5622,9 +8418,9 @@ var require_lib = __commonJS({
5622
8418
  };
5623
8419
  const sampleSize = (opts === null || opts === void 0 ? void 0 : opts.sampleSize) || 0;
5624
8420
  if (sampleSize > 0) {
5625
- fd = fs14.openSync(filepath, "r");
8421
+ fd = fs23.openSync(filepath, "r");
5626
8422
  let sample = Buffer.allocUnsafe(sampleSize);
5627
- fs14.read(fd, sample, 0, sampleSize, opts.offset, (err, bytesRead) => {
8423
+ fs23.read(fd, sample, 0, sampleSize, opts.offset, (err, bytesRead) => {
5628
8424
  if (err) {
5629
8425
  handler(err, null);
5630
8426
  } else {
@@ -5636,22 +8432,22 @@ var require_lib = __commonJS({
5636
8432
  });
5637
8433
  return;
5638
8434
  }
5639
- fs14.readFile(filepath, handler);
8435
+ fs23.readFile(filepath, handler);
5640
8436
  });
5641
8437
  exports2.detectFile = detectFile;
5642
8438
  var detectFileSync = (filepath, opts = {}) => {
5643
- const fs14 = (0, node_1.default)();
8439
+ const fs23 = (0, node_1.default)();
5644
8440
  if (opts && opts.sampleSize) {
5645
- const fd = fs14.openSync(filepath, "r");
8441
+ const fd = fs23.openSync(filepath, "r");
5646
8442
  let sample = Buffer.allocUnsafe(opts.sampleSize);
5647
- const bytesRead = fs14.readSync(fd, sample, 0, opts.sampleSize, opts.offset);
8443
+ const bytesRead = fs23.readSync(fd, sample, 0, opts.sampleSize, opts.offset);
5648
8444
  if (bytesRead < opts.sampleSize) {
5649
8445
  sample = sample.subarray(0, bytesRead);
5650
8446
  }
5651
- fs14.closeSync(fd);
8447
+ fs23.closeSync(fd);
5652
8448
  return (0, exports2.detect)(sample);
5653
8449
  }
5654
- return (0, exports2.detect)(fs14.readFileSync(filepath));
8450
+ return (0, exports2.detect)(fs23.readFileSync(filepath));
5655
8451
  };
5656
8452
  exports2.detectFileSync = detectFileSync;
5657
8453
  exports2.default = {
@@ -5788,6 +8584,7 @@ var DEFAULT_CONFIG_JSON5 = `{
5788
8584
  maxBlockFileSize: 50, // \u6700\u5927\u5206\u5757\u6587\u4EF6\u5927\u5C0F\uFF0C\u5355\u4F4DKB\uFF1B\u8D85\u8FC7\u8BE5\u5927\u5C0F\u7684\u6587\u4EF6\u9700\u8981\u5206\u5757\u5904\u7406
5789
8585
  encoding: 'auto', // \u547D\u4EE4\u884C\u7F16\u7801\u683C\u5F0F\uFF0C\u53EF\u8BBE\u7F6E\u4E3A utf-8\u3001gbk \u7B49\uFF0C\u4E5F\u53EF\u4EE5\u8BBE\u7F6E\u6210 auto \u6216\u7A7A\u503C\u81EA\u52A8\u5224\u65AD
5790
8586
  maxSubAgentCount: 2, // "\u6700\u5927\u5B50agent\u5E76\u884C\u6267\u884C\u6570\u91CF", -1 \u8868\u793A\u65E0\u9650\u5236
8587
+ isPrintThinking: true, // \u662F\u5426\u6253\u5370 AI \u601D\u8003\u8FC7\u7A0B\u4E2D\u7684\u4E2D\u95F4\u4FE1\u606F\uFF0C\u9ED8\u8BA4\u4E3A true
5791
8588
  serve: {
5792
8589
  port: 8866,
5793
8590
  }
@@ -5894,7 +8691,7 @@ function getScanDirPaths() {
5894
8691
  const workspacePath = getWorkspacePath();
5895
8692
  const homePath = getHomePath();
5896
8693
  const paths = /* @__PURE__ */ new Set();
5897
- paths.add(import_path2.default.join(workspacePath, ".deepfish"));
8694
+ paths.add(import_path2.default.join(workspacePath, ".deepfish-ai"));
5898
8695
  paths.add(import_path2.default.join(homePath));
5899
8696
  return Array.from(paths);
5900
8697
  }
@@ -6070,11 +8867,11 @@ function handleModelLs() {
6070
8867
  const currentModel = config2.currentModel;
6071
8868
  logInfo("=".repeat(50));
6072
8869
  aiList.forEach((item, index) => {
6073
- const isCurrent = item.name === currentModel ? "current" : " ";
8870
+ const isCurrent = item.name === currentModel;
6074
8871
  if (isCurrent) {
6075
- logSuccess(`[${index}] ${item.name} (${item.model}) [${isCurrent}]`);
8872
+ logSuccess(`[${index}] ${item.name} (${item.model}) [\u221A]`);
6076
8873
  } else {
6077
- logInfo(`[${index}] ${item.name} (${item.model})`);
8874
+ logInfo(`[${index}] ${item.name} (${item.model}) [\xD7]`);
6078
8875
  }
6079
8876
  });
6080
8877
  logInfo("=".repeat(50));
@@ -6140,9 +8937,9 @@ function registerModelsCommands(program) {
6140
8937
 
6141
8938
  // src/cli/cli-core/skills.ts
6142
8939
  var import_crypto5 = require("crypto");
6143
- var import_inquirer2 = __toESM(require("inquirer"));
6144
- var import_fs_extra12 = __toESM(require("fs-extra"));
6145
- var import_path14 = __toESM(require("path"));
8940
+ var import_inquirer3 = __toESM(require("inquirer"));
8941
+ var import_fs_extra19 = __toESM(require("fs-extra"));
8942
+ var import_path19 = __toESM(require("path"));
6146
8943
 
6147
8944
  // src/cli/cli-utils/init-config.ts
6148
8945
  var import_fs_extra4 = __toESM(require("fs-extra"));
@@ -6199,12 +8996,12 @@ function getConfig() {
6199
8996
  }
6200
8997
 
6201
8998
  // src/cli/cli-utils/init-agent.ts
6202
- var import_fs_extra11 = __toESM(require("fs-extra"));
6203
- var import_path13 = __toESM(require("path"));
8999
+ var import_fs_extra18 = __toESM(require("fs-extra"));
9000
+ var import_path18 = __toESM(require("path"));
6204
9001
  var import_crypto4 = require("crypto");
6205
9002
 
6206
9003
  // src/agent/AIAgent/index.ts
6207
- var import_langchain6 = require("langchain");
9004
+ var import_langchain15 = require("langchain");
6208
9005
  var import_deepagents = require("deepagents");
6209
9006
 
6210
9007
  // src/agent/AIAgent/utils/langgraph-checkpoint-filesystem/filesystem-saver.ts
@@ -6487,10 +9284,17 @@ var BaseCheckpointSaver = class {
6487
9284
  while (cursorConfig != null && remaining.size > 0) {
6488
9285
  const tup = await this.getTuple(cursorConfig);
6489
9286
  if (tup === void 0) break;
6490
- if (tup.pendingWrites && tup.pendingWrites.length > 0) for (let i = tup.pendingWrites.length - 1; i >= 0; i -= 1) {
6491
- const write = tup.pendingWrites[i];
6492
- const ch = write[1];
6493
- if (remaining.has(ch)) collectedByCh[ch].push(write);
9287
+ if (tup.pendingWrites && tup.pendingWrites.length > 0) {
9288
+ const perChannel = {};
9289
+ for (const write of tup.pendingWrites) {
9290
+ const ch = write[1];
9291
+ if (remaining.has(ch)) (perChannel[ch] ??= []).push(write);
9292
+ }
9293
+ for (const ch of Object.keys(perChannel)) {
9294
+ const block = perChannel[ch];
9295
+ block.sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
9296
+ for (let i = block.length - 1; i >= 0; i -= 1) collectedByCh[ch].push(block[i]);
9297
+ }
6494
9298
  }
6495
9299
  for (const ch of Array.from(remaining)) if (Object.prototype.hasOwnProperty.call(tup.checkpoint.channel_values, ch)) {
6496
9300
  seedByCh[ch] = tup.checkpoint.channel_values[ch];
@@ -7682,10 +10486,10 @@ function mergeDefs(...defs) {
7682
10486
  function cloneDef(schema) {
7683
10487
  return mergeDefs(schema._zod.def);
7684
10488
  }
7685
- function getElementAtPath(obj, path15) {
7686
- if (!path15)
10489
+ function getElementAtPath(obj, path21) {
10490
+ if (!path21)
7687
10491
  return obj;
7688
- return path15.reduce((acc, key) => acc?.[key], obj);
10492
+ return path21.reduce((acc, key) => acc?.[key], obj);
7689
10493
  }
7690
10494
  function promiseAllObject(promisesObj) {
7691
10495
  const keys = Object.keys(promisesObj);
@@ -8094,11 +10898,11 @@ function explicitlyAborted(x, startIndex = 0) {
8094
10898
  }
8095
10899
  return false;
8096
10900
  }
8097
- function prefixIssues(path15, issues) {
10901
+ function prefixIssues(path21, issues) {
8098
10902
  return issues.map((iss) => {
8099
10903
  var _a3;
8100
10904
  (_a3 = iss).path ?? (_a3.path = []);
8101
- iss.path.unshift(path15);
10905
+ iss.path.unshift(path21);
8102
10906
  return iss;
8103
10907
  });
8104
10908
  }
@@ -8245,16 +11049,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
8245
11049
  }
8246
11050
  function formatError(error51, mapper = (issue2) => issue2.message) {
8247
11051
  const fieldErrors = { _errors: [] };
8248
- const processError = (error52, path15 = []) => {
11052
+ const processError = (error52, path21 = []) => {
8249
11053
  for (const issue2 of error52.issues) {
8250
11054
  if (issue2.code === "invalid_union" && issue2.errors.length) {
8251
- issue2.errors.map((issues) => processError({ issues }, [...path15, ...issue2.path]));
11055
+ issue2.errors.map((issues) => processError({ issues }, [...path21, ...issue2.path]));
8252
11056
  } else if (issue2.code === "invalid_key") {
8253
- processError({ issues: issue2.issues }, [...path15, ...issue2.path]);
11057
+ processError({ issues: issue2.issues }, [...path21, ...issue2.path]);
8254
11058
  } else if (issue2.code === "invalid_element") {
8255
- processError({ issues: issue2.issues }, [...path15, ...issue2.path]);
11059
+ processError({ issues: issue2.issues }, [...path21, ...issue2.path]);
8256
11060
  } else {
8257
- const fullpath = [...path15, ...issue2.path];
11061
+ const fullpath = [...path21, ...issue2.path];
8258
11062
  if (fullpath.length === 0) {
8259
11063
  fieldErrors._errors.push(mapper(issue2));
8260
11064
  } else {
@@ -8281,17 +11085,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
8281
11085
  }
8282
11086
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
8283
11087
  const result = { errors: [] };
8284
- const processError = (error52, path15 = []) => {
11088
+ const processError = (error52, path21 = []) => {
8285
11089
  var _a3, _b;
8286
11090
  for (const issue2 of error52.issues) {
8287
11091
  if (issue2.code === "invalid_union" && issue2.errors.length) {
8288
- issue2.errors.map((issues) => processError({ issues }, [...path15, ...issue2.path]));
11092
+ issue2.errors.map((issues) => processError({ issues }, [...path21, ...issue2.path]));
8289
11093
  } else if (issue2.code === "invalid_key") {
8290
- processError({ issues: issue2.issues }, [...path15, ...issue2.path]);
11094
+ processError({ issues: issue2.issues }, [...path21, ...issue2.path]);
8291
11095
  } else if (issue2.code === "invalid_element") {
8292
- processError({ issues: issue2.issues }, [...path15, ...issue2.path]);
11096
+ processError({ issues: issue2.issues }, [...path21, ...issue2.path]);
8293
11097
  } else {
8294
- const fullpath = [...path15, ...issue2.path];
11098
+ const fullpath = [...path21, ...issue2.path];
8295
11099
  if (fullpath.length === 0) {
8296
11100
  result.errors.push(mapper(issue2));
8297
11101
  continue;
@@ -8323,8 +11127,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
8323
11127
  }
8324
11128
  function toDotPath(_path) {
8325
11129
  const segs = [];
8326
- const path15 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
8327
- for (const seg of path15) {
11130
+ const path21 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
11131
+ for (const seg of path21) {
8328
11132
  if (typeof seg === "number")
8329
11133
  segs.push(`[${seg}]`);
8330
11134
  else if (typeof seg === "symbol")
@@ -21016,13 +23820,13 @@ function resolveRef(ref, ctx) {
21016
23820
  if (!ref.startsWith("#")) {
21017
23821
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
21018
23822
  }
21019
- const path15 = ref.slice(1).split("/").filter(Boolean);
21020
- if (path15.length === 0) {
23823
+ const path21 = ref.slice(1).split("/").filter(Boolean);
23824
+ if (path21.length === 0) {
21021
23825
  return ctx.rootSchema;
21022
23826
  }
21023
23827
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
21024
- if (path15[0] === defsKey) {
21025
- const key = path15[1];
23828
+ if (path21[0] === defsKey) {
23829
+ const key = path21[1];
21026
23830
  if (!key || !ctx.defs[key]) {
21027
23831
  throw new Error(`Reference not found: ${ref}`);
21028
23832
  }
@@ -21489,38 +24293,135 @@ function createAgentEventMiddleware(emitter) {
21489
24293
  var Thinking = class {
21490
24294
  isThinking = false;
21491
24295
  loadingEvent = null;
21492
- content = "";
21493
- init() {
21494
- this.content = "";
21495
- this.isThinking = true;
21496
- this.loadingEvent = loading("Thinking...");
24296
+ start() {
24297
+ if (!this.isThinking) {
24298
+ this.isThinking = true;
24299
+ this.loadingEvent = loading("Thinking...");
24300
+ }
21497
24301
  }
21498
24302
  stop() {
21499
24303
  this.isThinking = false;
21500
- this.content = "";
21501
24304
  if (this.loadingEvent) {
21502
24305
  this.loadingEvent("I have finished thinking.");
21503
24306
  this.loadingEvent = null;
21504
24307
  }
21505
24308
  }
21506
- setStop(content) {
21507
- if (this.isThinking) {
21508
- this.content += content.replace(/\s+/g, "");
21509
- if (this.content.length > 0) {
21510
- this.stop();
21511
- }
21512
- }
21513
- }
21514
24309
  };
21515
24310
 
24311
+ // src/agent/AIAgent/utils/skill-parser.ts
24312
+ var fs5 = require("fs-extra");
24313
+ var path4 = require("path");
24314
+ var yaml = require_js_yaml();
24315
+ function extractFrontmatter(content, skillPath) {
24316
+ const normalizedContent = content.replace(/^\uFEFF/, "");
24317
+ const frontmatterMatch = normalizedContent.match(/^---\s*\r?\n([\s\S]*?)\r?\n---\s*(?:\r?\n|$)/);
24318
+ if (!frontmatterMatch) {
24319
+ throw new Error(`No frontmatter found in ${skillPath}`);
24320
+ }
24321
+ return frontmatterMatch[1];
24322
+ }
24323
+ function parseSkillMetadataYaml(skillPath) {
24324
+ const content = fs5.readFileSync(skillPath, "utf-8");
24325
+ const frontmatterContent = extractFrontmatter(content, skillPath);
24326
+ const frontmatter = yaml.load(frontmatterContent);
24327
+ return {
24328
+ name: frontmatter.name,
24329
+ description: frontmatter.description,
24330
+ homepage: frontmatter.homepage,
24331
+ location: path4.dirname(skillPath),
24332
+ metadata: frontmatter.metadata || {},
24333
+ skillFilePath: skillPath
24334
+ };
24335
+ }
24336
+
21516
24337
  // src/agent/AIAgent/system-prompt.ts
21517
- var systemPrompt = (workspace, osType) => `
21518
- \u8FD9\u662FDeepfish Cli\u7CFB\u7EDF\uFF0C\u4F60\u662F\u7CFB\u7EDF\u4E2D\u4E25\u683C\u6309\u89C4\u5219\u6267\u884C\u4EFB\u52A1\u7684\u667A\u80FD\u4F53\uFF0C\u4E0D\u80FD\u8FDD\u53CD\u4EFB\u4F55\u7CFB\u7EDF\u9650\u5236\u3002
24338
+ var import_fs_extra5 = __toESM(require("fs-extra"));
24339
+ function getSkillPrompt(skills) {
24340
+ const parsedSkills = skills.map((skill) => {
24341
+ return parseSkillMetadataYaml(skill);
24342
+ });
24343
+ let skillPrompt = "";
24344
+ if (parsedSkills.length > 0) {
24345
+ const skillTable = parsedSkills.map((s) => `| ${s.name} | ${s.description} | ${s.location} | ${s.skillFilePath} |`).join("\n");
24346
+ skillPrompt = `
24347
+ ### \u53EF\u4EE5\u4F7F\u7528\u7684Skills
24348
+ \u53EF\u4EE5\u8C03\u7528\u4EE5\u4E0BSkill\u6765\u5B8C\u6210\u7528\u6237\u4EFB\u52A1\u76EE\u6807,Skill\u7684\u8C03\u7528\u65B9\u5F0F:
24349
+ - \u4F7F\u7528\u7528\u6237\u8BF7\u6C42\u5339\u914D skill description,
24350
+ - \u4E00\u6B21\u53EA\u52A0\u8F7D\u4E00\u4E2ASkill,\u4F18\u5148\u5339\u914D\u6700\u5177\u4F53\u7684Skill
24351
+ - \u5F53\u7528\u6237\u8BF7\u6C42\u4E0D\u5339\u914D\u4EFB\u4F55Skill\u63CF\u8FF0\u65F6,\u4E0D\u52A0\u8F7D\u4EFB\u4F55Skill
24352
+ - \u5F53\u5339\u914D\u5230Skill\u65F6, \u521B\u5EFA\u4E00\u4E2A\u5B50\u667A\u80FD\u4F53,\u5C06SKILL.md\u7684\u6587\u4EF6\u8DEF\u5F84\u548C\u4EFB\u52A1\u76EE\u6807\u4F20\u9012\u7ED9\u5B50\u667A\u80FD\u4F53,\u5B50\u667A\u80FD\u4F53\u901A\u8FC7\u8BFB\u53D6SKILL.md\u6587\u4EF6\u83B7\u53D6\u8C03\u7528\u8BF4\u660E,\u901A\u8FC7\u4ED4\u7EC6\u9605\u8BFB\u8BF4\u660E\u6587\u4EF6\u5B66\u4E60Skill\u7684\u4F7F\u7528\u65B9\u6CD5\u6765\u5B8C\u6210\u4EFB\u52A1
24353
+ ## Available Skills
24354
+
24355
+ | Skill | Type | Description | Location | SkillFilePath |
24356
+ |-------|------|-------------|----------|---------------|
24357
+ ${skillTable}
24358
+ |-------|------|-------------|----------|---------------|
24359
+ `;
24360
+ }
24361
+ return skillPrompt;
24362
+ }
24363
+ function getUserMemoryPrompt(memoryFilePath) {
24364
+ if (!memoryFilePath) {
24365
+ return "";
24366
+ }
24367
+ if (import_fs_extra5.default.existsSync(memoryFilePath)) {
24368
+ const content = import_fs_extra5.default.readFileSync(memoryFilePath, "utf-8");
24369
+ return `
24370
+ ### \u7528\u6237\u4FE1\u606F
24371
+ ${content}
24372
+ `;
24373
+ }
24374
+ return "";
24375
+ }
24376
+ function getAgentRulesPrompt(agentRulesPath) {
24377
+ if (!agentRulesPath) {
24378
+ return "";
24379
+ }
24380
+ if (import_fs_extra5.default.existsSync(agentRulesPath)) {
24381
+ const content = import_fs_extra5.default.readFileSync(agentRulesPath, "utf-8");
24382
+ return `### \u4EE5\u4E0B\u662FAgent\u884C\u4E3A\u89C4\u8303\uFF0C\u5FC5\u987B\u4E25\u683C\u9075\u5B88\uFF1A
24383
+ ${content}
24384
+ `;
24385
+ }
24386
+ }
24387
+ var systemPrompt = (workspace, osType, skills, memoryFilePath, agentRulesPath) => {
24388
+ const skillPrompt = getSkillPrompt(skills);
24389
+ const memoryPrompt = getUserMemoryPrompt(memoryFilePath);
24390
+ const agentRulesPrompt = getAgentRulesPrompt(agentRulesPath);
24391
+ return `
24392
+ \u8FD9\u662FDeepfish Cli\u7CFB\u7EDF,\u4F60\u662F\u7CFB\u7EDF\u4E2D\u4E25\u683C\u6309\u89C4\u5219\u6267\u884C\u4EFB\u52A1\u7684\u667A\u80FD\u4F53,\u4E0D\u80FD\u8FDD\u53CD\u4EFB\u4F55\u7CFB\u7EDF\u9650\u5236\u3002
24393
+ ### \u57FA\u7840\u73AF\u5883\u4FE1\u606F
24394
+ \u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\uFF1A${workspace}
24395
+ \u64CD\u4F5C\u7CFB\u7EDF\u7C7B\u578B\uFF1A${osType}
24396
+ \u8BED\u8A00\u7C7B\u578B: \u4E0E\u7528\u6237\u8F93\u5165\u8BED\u8A00\u4E00\u81F4
24397
+
24398
+ \u6CE8\u610F:
24399
+ 1.\u5982\u679C\u4EFB\u52A1\u6BD4\u8F83\u590D\u6742\uFF0C\u5E94\u8BE5\u5148\u8FDB\u884C\u62C6\u5206\uFF0C\u5206\u89E3\u6210\u591A\u4E2A\u6B65\u9AA4\uFF0C\u521B\u5EFA\u5B50\u667A\u80FD\u4F53\u6765\u9010\u6B65\u5B8C\u6210\u3002
24400
+ 2.\u4E34\u65F6\u6587\u4EF6\u5FC5\u987B\u4F7F\u7528"tmp_"\u4F5C\u4E3A\u524D\u7F00\u547D\u540D\uFF0C\u5E76\u5728\u4EFB\u52A1\u7ED3\u675F\u540E\u5220\u9664\uFF0C\u4E0D\u80FD\u5728\u5DE5\u4F5C\u76EE\u5F55\u4E2D\u7559\u4E0B\u4EFB\u4F55\u4E34\u65F6\u6587\u4EF6\u3002
24401
+ 3.\u5C3D\u91CF\u4F7F\u7528"execute_command"\u3001"execute_js_code"\u5DE5\u5177\u5B8C\u6210\u4EFB\u52A1
24402
+
24403
+ ${skillPrompt}
24404
+ ${memoryPrompt}
24405
+ ${agentRulesPrompt}
24406
+ `;
24407
+ };
24408
+ var subSystemPrompt = (workspace, osType, skills) => {
24409
+ let skillPrompt = getSkillPrompt(skills);
24410
+ return `
24411
+ \u8FD9\u662FDeepfish Cli\u7CFB\u7EDF,\u4F60\u662F\u7CFB\u7EDF\u4E2D\u4E25\u683C\u6309\u89C4\u5219\u6267\u884C\u4EFB\u52A1\u7684\u5B50\u667A\u80FD\u4F53,\u4E0D\u80FD\u8FDD\u53CD\u4EFB\u4F55\u7CFB\u7EDF\u9650\u5236\u3002
21519
24412
  ### \u57FA\u7840\u73AF\u5883\u4FE1\u606F
21520
24413
  \u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\uFF1A${workspace}
21521
24414
  \u64CD\u4F5C\u7CFB\u7EDF\u7C7B\u578B\uFF1A${osType}
21522
24415
  \u8BED\u8A00\u7C7B\u578B: \u4E0E\u7528\u6237\u8F93\u5165\u8BED\u8A00\u4E00\u81F4
24416
+
24417
+ \u6CE8\u610F:
24418
+ 1.\u5B50\u667A\u80FD\u4F53\u53EA\u80FD\u5B8C\u6210\u5355\u4E2A\u4EFB\u52A1,\u4E0D\u80FD\u521B\u5EFA\u65B0\u7684\u5B50\u667A\u80FD\u4F53\u3002
24419
+ 2.\u4E34\u65F6\u6587\u4EF6\u5FC5\u987B\u4F7F\u7528"tmp_"\u4F5C\u4E3A\u524D\u7F00\u547D\u540D\uFF0C\u5E76\u5728\u4EFB\u52A1\u7ED3\u675F\u540E\u5220\u9664\uFF0C\u4E0D\u80FD\u5728\u5DE5\u4F5C\u76EE\u5F55\u4E2D\u7559\u4E0B\u4EFB\u4F55\u4E34\u65F6\u6587\u4EF6\u3002
24420
+ 3.\u5C3D\u91CF\u4F7F\u7528"execute_command"\u3001"execute_js_code"\u5DE5\u5177\u5B8C\u6210\u4EFB\u52A1
24421
+
24422
+ ${skillPrompt}
21523
24423
  `;
24424
+ };
21524
24425
 
21525
24426
  // src/agent/tools/executeCommand.ts
21526
24427
  var import_child_process2 = require("child_process");
@@ -21531,13 +24432,13 @@ var import_langchain2 = require("langchain");
21531
24432
 
21532
24433
  // src/cli/cli-utils/getGlobalData.ts
21533
24434
  var import_path6 = __toESM(require("path"));
21534
- var import_fs_extra5 = __toESM(require("fs-extra"));
24435
+ var import_fs_extra6 = __toESM(require("fs-extra"));
21535
24436
  function getServePort() {
21536
24437
  const port = getConfig()?.serve?.port || 8866;
21537
24438
  return port;
21538
24439
  }
21539
24440
  function getVersion() {
21540
- const packageJson = import_fs_extra5.default.readJSONSync(import_path6.default.join(getCodePath(), "package.json"));
24441
+ const packageJson = import_fs_extra6.default.readJSONSync(import_path6.default.join(getCodePath(), "package.json"));
21541
24442
  return packageJson.version;
21542
24443
  }
21543
24444
  function getEncoding() {
@@ -21607,7 +24508,7 @@ var executeCommandTool = (0, import_langchain2.tool)(
21607
24508
  // src/agent/tools/executeJSCode.ts
21608
24509
  var import_langchain3 = require("langchain");
21609
24510
  var import_path7 = __toESM(require("path"));
21610
- var import_fs_extra6 = __toESM(require("fs-extra"));
24511
+ var import_fs_extra7 = __toESM(require("fs-extra"));
21611
24512
  var _require = require;
21612
24513
  async function executeJSCode(code) {
21613
24514
  logInfo("Executing JavaScript code: ");
@@ -21629,7 +24530,7 @@ async function executeJSCode(code) {
21629
24530
  var getInstalledPackagesTool = (0, import_langchain3.tool)(
21630
24531
  async () => {
21631
24532
  const packageJson = import_path7.default.join(getCodePath(), "./package.json");
21632
- const pkg = import_fs_extra6.default.readJsonSync(packageJson);
24533
+ const pkg = import_fs_extra7.default.readJsonSync(packageJson);
21633
24534
  return JSON.stringify(pkg.dependencies);
21634
24535
  },
21635
24536
  {
@@ -21641,7 +24542,7 @@ var getInstalledPackagesTool = (0, import_langchain3.tool)(
21641
24542
  var checkPackageInstalledTool = (0, import_langchain3.tool)(
21642
24543
  async ({ packageName }) => {
21643
24544
  const packageJson = import_path7.default.join(getCodePath(), "./package.json");
21644
- const pkg = import_fs_extra6.default.readJsonSync(packageJson);
24545
+ const pkg = import_fs_extra7.default.readJsonSync(packageJson);
21645
24546
  const installed = Object.prototype.hasOwnProperty.call(pkg.dependencies, packageName);
21646
24547
  return installed ? `Package "${packageName}" is installed.` : `Package "${packageName}" is NOT installed.`;
21647
24548
  },
@@ -21656,7 +24557,7 @@ var checkPackageInstalledTool = (0, import_langchain3.tool)(
21656
24557
  var installPackageTool = (0, import_langchain3.tool)(
21657
24558
  async ({ packageName }) => {
21658
24559
  const packageJson = import_path7.default.join(getCodePath(), "./package.json");
21659
- const pkg = import_fs_extra6.default.readJsonSync(packageJson);
24560
+ const pkg = import_fs_extra7.default.readJsonSync(packageJson);
21660
24561
  if (Object.prototype.hasOwnProperty.call(pkg.dependencies, packageName)) {
21661
24562
  return `Package "${packageName}" is already installed.`;
21662
24563
  }
@@ -21670,7 +24571,6 @@ var installPackageTool = (0, import_langchain3.tool)(
21670
24571
  })
21671
24572
  }
21672
24573
  );
21673
- var packageTools = [getInstalledPackagesTool, checkPackageInstalledTool, installPackageTool];
21674
24574
  var executeJSCodeTool = (0, import_langchain3.tool)(
21675
24575
  async ({ code }) => {
21676
24576
  const result = await executeJSCode(code);
@@ -21678,21 +24578,22 @@ var executeJSCodeTool = (0, import_langchain3.tool)(
21678
24578
  },
21679
24579
  {
21680
24580
  name: "execute_js_code",
21681
- description: `\u5728\u5F53\u524D Node.js \u73AF\u5883\u4E2D\u6267\u884C\u4E00\u6BB5 JavaScript \u4EE3\u7801\u5B57\u7B26\u4E32\u5E76\u8FD4\u56DE\u6267\u884C\u7ED3\u679C\u3002\u6CE8\u610F\uFF1A\u4EE3\u7801\u5FC5\u987B\u5305\u542B\u4E00\u4E2A__main()\u51FD\u6570\u4F5C\u4E3A\u6267\u884C\u5165\u53E3\uFF0C__main()\u51FD\u6570\u5185\u5FC5\u987B\u662F\u4E00\u4E2A\u4F7F\u7528async\u524D\u7F00\u7684\u51FD\u6570\u3002\u793A\u4F8B\u4EE3\u7801\uFF1A
24581
+ description: `\u6267\u884C\u4E00\u6BB5Node.js\u4EE3\u7801\u5E76\u8FD4\u56DE\u6267\u884C\u7ED3\u679C\u3002\u6CE8\u610F\uFF1A\u4EE3\u7801\u5FC5\u987B\u5305\u542B\u4E00\u4E2A__main()\u51FD\u6570\u4F5C\u4E3A\u6267\u884C\u5165\u53E3\uFF0C__main()\u51FD\u6570\u5185\u5FC5\u987B\u662F\u4E00\u4E2A\u4F7F\u7528async\u524D\u7F00\u7684\u51FD\u6570\u3002\u793A\u4F8B\u4EE3\u7801\uFF1A
21682
24582
  async function __main() {
21683
24583
  const data = await fs.readFile("data.txt", "utf-8")
21684
24584
  return data
21685
24585
  }
21686
24586
  `,
21687
24587
  schema: external_exports.object({
21688
- code: external_exports.string().describe("\u8981\u6267\u884C\u7684 JavaScript \u4EE3\u7801")
24588
+ code: external_exports.string().describe("\u8981\u6267\u884C\u7684Node.js\u4EE3\u7801")
21689
24589
  })
21690
24590
  }
21691
24591
  );
24592
+ var packageTools = [getInstalledPackagesTool, checkPackageInstalledTool, installPackageTool, executeJSCodeTool];
21692
24593
 
21693
24594
  // src/cli/cli-utils/UserCache.ts
21694
24595
  var import_path8 = __toESM(require("path"));
21695
- var import_fs_extra7 = __toESM(require("fs-extra"));
24596
+ var import_fs_extra8 = __toESM(require("fs-extra"));
21696
24597
  var import_crypto = require("crypto");
21697
24598
  var UserCache = class {
21698
24599
  cacheDir;
@@ -21700,23 +24601,23 @@ var UserCache = class {
21700
24601
  constructor() {
21701
24602
  const cacheDir = getUserStorePath();
21702
24603
  const catalog = import_path8.default.join(cacheDir, "catalog.json");
21703
- import_fs_extra7.default.ensureFileSync(catalog);
24604
+ import_fs_extra8.default.ensureFileSync(catalog);
21704
24605
  this.cacheDir = cacheDir;
21705
24606
  this.catalogPath = catalog;
21706
24607
  }
21707
24608
  getCatalog() {
21708
- return import_fs_extra7.default.readJSONSync(this.catalogPath, { throws: false }) || [];
24609
+ return import_fs_extra8.default.readJSONSync(this.catalogPath, { throws: false }) || [];
21709
24610
  }
21710
24611
  getCatalogFilePath() {
21711
24612
  return this.catalogPath;
21712
24613
  }
21713
24614
  updateCatalog(catalog) {
21714
- import_fs_extra7.default.writeJSONSync(this.catalogPath, catalog);
24615
+ import_fs_extra8.default.writeJSONSync(this.catalogPath, catalog);
21715
24616
  }
21716
24617
  add(description, content) {
21717
24618
  const id = (0, import_crypto.randomUUID)();
21718
24619
  const filePath = import_path8.default.join(this.cacheDir, `${id}.md`);
21719
- import_fs_extra7.default.writeFileSync(filePath, content, "utf-8");
24620
+ import_fs_extra8.default.writeFileSync(filePath, content, "utf-8");
21720
24621
  const catalog = this.getCatalog();
21721
24622
  catalog.push({ id, description });
21722
24623
  this.updateCatalog(catalog);
@@ -21726,8 +24627,8 @@ var UserCache = class {
21726
24627
  const item = catalog.find((item2) => item2.id === id);
21727
24628
  if (item) {
21728
24629
  const filePath = import_path8.default.join(this.cacheDir, `${id}.md`);
21729
- if (import_fs_extra7.default.existsSync(filePath)) {
21730
- return { description: item.description, content: import_fs_extra7.default.readFileSync(filePath, "utf-8") };
24630
+ if (import_fs_extra8.default.existsSync(filePath)) {
24631
+ return { description: item.description, content: import_fs_extra8.default.readFileSync(filePath, "utf-8") };
21731
24632
  }
21732
24633
  }
21733
24634
  return { description: "", content: "" };
@@ -21751,8 +24652,8 @@ var UserCache = class {
21751
24652
  catalog.splice(idx, 1);
21752
24653
  this.updateCatalog(catalog);
21753
24654
  const filePath = import_path8.default.join(this.cacheDir, `${id}.md`);
21754
- if (import_fs_extra7.default.existsSync(filePath)) {
21755
- import_fs_extra7.default.removeSync(filePath);
24655
+ if (import_fs_extra8.default.existsSync(filePath)) {
24656
+ import_fs_extra8.default.removeSync(filePath);
21756
24657
  }
21757
24658
  return true;
21758
24659
  }
@@ -21771,7 +24672,7 @@ var UserCache = class {
21771
24672
  return false;
21772
24673
  }
21773
24674
  const filePath = import_path8.default.join(this.cacheDir, `${id}.md`);
21774
- import_fs_extra7.default.writeFileSync(filePath, content, "utf-8");
24675
+ import_fs_extra8.default.writeFileSync(filePath, content, "utf-8");
21775
24676
  return true;
21776
24677
  }
21777
24678
  };
@@ -21853,44 +24754,49 @@ var learnTools = [learnSelfTool, getLearnedDetailTool, updateLearnContentTool, g
21853
24754
 
21854
24755
  // src/agent/tools/mcp.ts
21855
24756
  var import_mcp_adapters = require("@langchain/mcp-adapters");
21856
- var import_fs_extra8 = __toESM(require("fs-extra"));
24757
+ var import_fs_extra9 = __toESM(require("fs-extra"));
21857
24758
  var import_path9 = __toESM(require("path"));
21858
24759
  async function loadMcpToolsFromConfigPath(mcpFilePath) {
21859
- const jsonContent = import_fs_extra8.default.readJSONSync(mcpFilePath);
24760
+ const jsonContent = import_fs_extra9.default.readJSONSync(mcpFilePath);
21860
24761
  const { mcpServers } = jsonContent;
21861
- if (!mcpServers || mcpServers.length === 0) {
24762
+ if (!mcpServers || Object.keys(mcpServers).length === 0) {
21862
24763
  return [];
21863
24764
  }
21864
- for (const key of Object.keys(mcpServers)) {
21865
- const server = mcpServers[key];
21866
- if (!server.transport) {
21867
- if (server.url) {
21868
- if (server.url.startsWith("ws://") || server.url.startsWith("wss://")) {
21869
- server.transport = "websocket";
21870
- } else if (server.url.startsWith("http://") || server.url.startsWith("https://")) {
21871
- server.transport = "http";
24765
+ try {
24766
+ for (const key of Object.keys(mcpServers)) {
24767
+ const server = mcpServers[key];
24768
+ if (!server.transport) {
24769
+ if (server.url) {
24770
+ if (server.url.startsWith("ws://") || server.url.startsWith("wss://")) {
24771
+ server.transport = "websocket";
24772
+ } else if (server.url.startsWith("http://") || server.url.startsWith("https://")) {
24773
+ server.transport = "http";
24774
+ }
24775
+ } else if (server.command === "node" || server.command === "npx") {
24776
+ server.transport = "stdio";
21872
24777
  }
21873
- } else if (server.command === "node" || server.command === "npx") {
21874
- server.transport = "stdio";
24778
+ }
24779
+ if (!server.transport) {
24780
+ logWarning(`Unable to determine transport for MCP server ${key}, skipping...`);
24781
+ delete mcpServers[key];
21875
24782
  }
21876
24783
  }
21877
- if (!server.transport) {
21878
- logWarning(`Unable to determine transport for MCP server ${key}, skipping...`);
21879
- delete mcpServers[key];
21880
- }
24784
+ logInfo(`Loading MCP tools from config path: ${mcpFilePath}`);
24785
+ const client = new import_mcp_adapters.MultiServerMCPClient(jsonContent.mcpServers);
24786
+ const tools = await client.getTools();
24787
+ logInfo(`Loaded ${tools.length} tools from MCP config.`);
24788
+ return tools;
24789
+ } catch (error51) {
24790
+ console.log("Error loading MCP tools:", error51);
24791
+ return [];
21881
24792
  }
21882
- logInfo(`Loading MCP tools from config path: ${mcpFilePath}`);
21883
- const client = new import_mcp_adapters.MultiServerMCPClient(jsonContent.mcpServers);
21884
- const tools = await client.getTools();
21885
- logInfo(`Loaded ${tools.length} tools from MCP config.`);
21886
- return tools;
21887
24793
  }
21888
24794
  async function scanUserMcp() {
21889
24795
  const tools = [];
21890
24796
  const scanPaths = getScanDirPaths();
21891
24797
  for (const scanPath of scanPaths) {
21892
24798
  const mcpFilePath = import_path9.default.join(scanPath, "mcp.json");
21893
- if (import_fs_extra8.default.existsSync(mcpFilePath)) {
24799
+ if (import_fs_extra9.default.existsSync(mcpFilePath)) {
21894
24800
  const mcpTools = await loadMcpToolsFromConfigPath(mcpFilePath);
21895
24801
  tools.push(...mcpTools);
21896
24802
  }
@@ -21901,7 +24807,7 @@ async function scanUserMcp() {
21901
24807
  // src/agent/tools/utils.ts
21902
24808
  var import_langchain5 = require("langchain");
21903
24809
  var import_path10 = __toESM(require("path"));
21904
- var import_fs_extra9 = __toESM(require("fs-extra"));
24810
+ var import_fs_extra10 = __toESM(require("fs-extra"));
21905
24811
  var import_crypto2 = require("crypto");
21906
24812
  function toLangChainTool(func, description) {
21907
24813
  const { name, description: desc, parameters } = description.function;
@@ -21951,12 +24857,12 @@ function scanUserTools() {
21951
24857
  const scanPaths = getScanDirPaths();
21952
24858
  scanPaths.forEach((scanPath) => {
21953
24859
  const toolsDir = import_path10.default.resolve(scanPath, "tools");
21954
- if (import_fs_extra9.default.pathExistsSync(toolsDir)) {
21955
- const files = import_fs_extra9.default.readdirSync(toolsDir);
24860
+ if (import_fs_extra10.default.pathExistsSync(toolsDir)) {
24861
+ const files = import_fs_extra10.default.readdirSync(toolsDir);
21956
24862
  files.forEach((file2) => {
21957
- if (import_fs_extra9.default.statSync(import_path10.default.resolve(toolsDir, file2)).isDirectory()) {
24863
+ if (import_fs_extra10.default.statSync(import_path10.default.resolve(toolsDir, file2)).isDirectory()) {
21958
24864
  const subDirPath = import_path10.default.resolve(toolsDir, file2);
21959
- const subFiles = import_fs_extra9.default.readdirSync(subDirPath);
24865
+ const subFiles = import_fs_extra10.default.readdirSync(subDirPath);
21960
24866
  const indexFile = subFiles.find((f) => f === "index" || f === "index.cjs");
21961
24867
  if (indexFile) {
21962
24868
  const filePath = _scanDeepFishJsFile(import_path10.default.resolve(subDirPath, indexFile), indexFile);
@@ -21984,7 +24890,7 @@ function scanUserTools() {
21984
24890
  }
21985
24891
  function _scanDeepFishJsFile(filePath, fileName) {
21986
24892
  if (fileName.endsWith(".js") || fileName.endsWith(".cjs")) {
21987
- const fileContent = import_fs_extra9.default.readFileSync(filePath, "utf-8");
24893
+ const fileContent = import_fs_extra10.default.readFileSync(filePath, "utf-8");
21988
24894
  if (fileContent.includes("module.exports") && fileContent.includes("descriptions") && fileContent.includes("functions")) {
21989
24895
  return filePath;
21990
24896
  }
@@ -22003,21 +24909,381 @@ function _loadToolsFromFile(filePath, tools) {
22003
24909
  });
22004
24910
  }
22005
24911
 
22006
- // src/agent/tools/index.ts
22007
- async function getTools() {
22008
- return [executeCommandTool, executeJSCodeTool, ...packageTools, ...learnTools, ...await scanUserTools(), ...await scanUserMcp()];
22009
- }
24912
+ // src/agent/tools/edit.ts
24913
+ var import_fs_extra12 = __toESM(require("fs-extra"));
24914
+ var import_langchain6 = require("langchain");
22010
24915
 
22011
- // src/agent/skills/index.ts
24916
+ // src/agent/tools/fileTools.ts
24917
+ var import_fs_extra11 = __toESM(require("fs-extra"));
22012
24918
  var import_path11 = __toESM(require("path"));
22013
- function getSkills() {
22014
- return [...getRegisteredSkills(), import_path11.default.join(__dirname, "./view-learn-cache.md")];
24919
+ var DEFAULT_MAX_OUTPUT = 6e4;
24920
+ var TEXT_FILE_EXTENSIONS = /* @__PURE__ */ new Set([
24921
+ ".txt",
24922
+ ".md",
24923
+ ".json",
24924
+ ".json5",
24925
+ ".js",
24926
+ ".jsx",
24927
+ ".ts",
24928
+ ".tsx",
24929
+ ".mjs",
24930
+ ".cjs",
24931
+ ".css",
24932
+ ".less",
24933
+ ".scss",
24934
+ ".html",
24935
+ ".xml",
24936
+ ".yaml",
24937
+ ".yml",
24938
+ ".toml",
24939
+ ".ini",
24940
+ ".env",
24941
+ ".gitignore",
24942
+ ".sql",
24943
+ ".py",
24944
+ ".java",
24945
+ ".c",
24946
+ ".cpp",
24947
+ ".h",
24948
+ ".hpp",
24949
+ ".cs",
24950
+ ".go",
24951
+ ".rs",
24952
+ ".php",
24953
+ ".rb",
24954
+ ".sh",
24955
+ ".bat",
24956
+ ".ps1",
24957
+ ".vue",
24958
+ ".svelte",
24959
+ ".log",
24960
+ ".csv"
24961
+ ]);
24962
+ function resolveWorkspacePath(inputPath, cwd = getTrueCwd()) {
24963
+ if (!inputPath?.trim()) {
24964
+ throw new Error("\u8DEF\u5F84\u4E0D\u80FD\u4E3A\u7A7A");
24965
+ }
24966
+ return import_path11.default.resolve(cwd, inputPath);
24967
+ }
24968
+ function normalizePathForMatch(filePath) {
24969
+ return filePath.replace(/\\/g, "/");
24970
+ }
24971
+ function truncateOutput(content, maxLength = DEFAULT_MAX_OUTPUT) {
24972
+ if (content.length <= maxLength) {
24973
+ return content;
24974
+ }
24975
+ return `${content.slice(0, maxLength)}
24976
+
24977
+ [\u5185\u5BB9\u5DF2\u622A\u65AD\uFF0C\u4EC5\u663E\u793A\u524D ${maxLength} \u4E2A\u5B57\u7B26\uFF0C\u603B\u957F\u5EA6 ${content.length} \u4E2A\u5B57\u7B26]`;
24978
+ }
24979
+ function isProbablyTextFile(filePath) {
24980
+ const ext = import_path11.default.extname(filePath).toLowerCase();
24981
+ const base = import_path11.default.basename(filePath).toLowerCase();
24982
+ return TEXT_FILE_EXTENSIONS.has(ext) || TEXT_FILE_EXTENSIONS.has(base) || base.startsWith(".env");
24983
+ }
24984
+ function globToRegExp(pattern) {
24985
+ const normalized = normalizePathForMatch(pattern);
24986
+ let regex = "^";
24987
+ for (let i = 0; i < normalized.length; i++) {
24988
+ const char = normalized[i];
24989
+ const next = normalized[i + 1];
24990
+ if (char === "*") {
24991
+ if (next === "*") {
24992
+ const after = normalized[i + 2];
24993
+ if (after === "/") {
24994
+ regex += "(?:.*/)?";
24995
+ i += 2;
24996
+ } else {
24997
+ regex += ".*";
24998
+ i += 1;
24999
+ }
25000
+ } else {
25001
+ regex += "[^/]*";
25002
+ }
25003
+ } else if (char === "?") {
25004
+ regex += "[^/]";
25005
+ } else {
25006
+ regex += char.replace(/[|\\{}()[\]^$+?.]/g, "\\$&");
25007
+ }
25008
+ }
25009
+ regex += "$";
25010
+ return new RegExp(regex, "i");
25011
+ }
25012
+ function matchesGlob(relativePath, pattern) {
25013
+ return globToRegExp(pattern).test(normalizePathForMatch(relativePath));
25014
+ }
25015
+ async function walkFiles(rootDir, options = {}) {
25016
+ const files = [];
25017
+ const includeHidden = options.includeHidden ?? false;
25018
+ const maxFiles = options.maxFiles ?? 5e3;
25019
+ async function walk(currentDir) {
25020
+ if (files.length >= maxFiles) {
25021
+ return;
25022
+ }
25023
+ const entries = await import_fs_extra11.default.readdir(currentDir, { withFileTypes: true });
25024
+ for (const entry of entries) {
25025
+ if (files.length >= maxFiles) {
25026
+ return;
25027
+ }
25028
+ if (!includeHidden && entry.name.startsWith(".")) {
25029
+ continue;
25030
+ }
25031
+ if (entry.name === "node_modules" || entry.name === "dist" || entry.name === ".git") {
25032
+ continue;
25033
+ }
25034
+ const fullPath = import_path11.default.join(currentDir, entry.name);
25035
+ if (entry.isDirectory()) {
25036
+ await walk(fullPath);
25037
+ } else if (entry.isFile()) {
25038
+ files.push(fullPath);
25039
+ }
25040
+ }
25041
+ }
25042
+ await walk(rootDir);
25043
+ return files;
25044
+ }
25045
+ function formatJson(data) {
25046
+ return JSON.stringify(data, null, 2);
25047
+ }
25048
+
25049
+ // src/agent/tools/edit.ts
25050
+ async function editFileByReplace(filePath, oldString, newString, replaceAll = false) {
25051
+ const absPath = resolveWorkspacePath(filePath);
25052
+ if (!await import_fs_extra12.default.pathExists(absPath)) {
25053
+ return `Edit error: \u6587\u4EF6\u4E0D\u5B58\u5728 ${absPath}`;
25054
+ }
25055
+ const content = await import_fs_extra12.default.readFile(absPath, "utf-8");
25056
+ const matches = content.split(oldString).length - 1;
25057
+ if (!oldString) {
25058
+ return "Edit error: oldString \u4E0D\u80FD\u4E3A\u7A7A";
25059
+ }
25060
+ if (matches === 0) {
25061
+ return "Edit error: \u672A\u627E\u5230 oldString\uFF0C\u8BF7\u5148\u8BFB\u53D6\u6587\u4EF6\u786E\u8BA4\u7CBE\u786E\u5185\u5BB9";
25062
+ }
25063
+ if (!replaceAll && matches > 1) {
25064
+ return `Edit error: oldString \u5339\u914D\u5230 ${matches} \u5904\u3002\u8BF7\u63D0\u4F9B\u66F4\u591A\u4E0A\u4E0B\u6587\u4F7F\u5176\u552F\u4E00\uFF0C\u6216\u8BBE\u7F6E replaceAll=true`;
25065
+ }
25066
+ const nextContent = replaceAll ? content.split(oldString).join(newString) : content.replace(oldString, newString);
25067
+ await import_fs_extra12.default.writeFile(absPath, nextContent, "utf-8");
25068
+ return `\u5DF2\u7F16\u8F91\u6587\u4EF6: ${absPath}\uFF0C\u66FF\u6362 ${replaceAll ? matches : 1} \u5904`;
25069
+ }
25070
+ var editFileTool = (0, import_langchain6.tool)(
25071
+ async ({ filePath, oldString, newString, replaceAll }) => editFileByReplace(filePath, oldString, newString, replaceAll),
25072
+ {
25073
+ name: "edit_file",
25074
+ description: "\u7F16\u8F91\u5DF2\u6709\u6587\u672C\u6587\u4EF6\uFF1A\u4F7F\u7528\u7CBE\u786E oldString \u66FF\u6362\u4E3A newString\u3002\u9ED8\u8BA4\u8981\u6C42 oldString \u5728\u6587\u4EF6\u4E2D\u552F\u4E00\uFF0C\u4EE5\u907F\u514D\u8BEF\u6539\u3002",
25075
+ schema: external_exports.object({
25076
+ filePath: external_exports.string().describe("\u8981\u7F16\u8F91\u7684\u6587\u4EF6\u8DEF\u5F84\uFF0C\u652F\u6301\u7EDD\u5BF9\u8DEF\u5F84\u6216\u76F8\u5BF9\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u7684\u8DEF\u5F84"),
25077
+ oldString: external_exports.string().describe("\u8981\u66FF\u6362\u7684\u539F\u59CB\u6587\u672C\uFF0C\u5FC5\u987B\u4E0E\u6587\u4EF6\u5185\u5BB9\u5B8C\u5168\u4E00\u81F4\uFF1B\u5EFA\u8BAE\u5305\u542B\u8DB3\u591F\u4E0A\u4E0B\u6587\u4FDD\u8BC1\u552F\u4E00"),
25078
+ newString: external_exports.string().describe("\u66FF\u6362\u540E\u7684\u65B0\u6587\u672C"),
25079
+ replaceAll: external_exports.boolean().default(false).describe("\u662F\u5426\u66FF\u6362\u5168\u90E8\u5339\u914D\u9879\uFF1B\u9ED8\u8BA4 false\uFF0C\u4EC5\u5141\u8BB8\u552F\u4E00\u5339\u914D")
25080
+ })
25081
+ }
25082
+ );
25083
+
25084
+ // src/agent/tools/glob.ts
25085
+ var import_path12 = __toESM(require("path"));
25086
+ var import_langchain7 = require("langchain");
25087
+ async function globFiles(pattern, cwd, maxResults = 200, includeHidden = false) {
25088
+ const rootDir = resolveWorkspacePath(cwd || ".");
25089
+ const allFiles = await walkFiles(rootDir, { includeHidden, maxFiles: Math.max(maxResults * 20, 1e3) });
25090
+ const normalizedPattern = normalizePathForMatch(pattern);
25091
+ const matches = allFiles.map((file2) => normalizePathForMatch(import_path12.default.relative(rootDir, file2))).filter((relativePath) => matchesGlob(relativePath, normalizedPattern)).slice(0, maxResults);
25092
+ return truncateOutput(formatJson({ cwd: rootDir, pattern, count: matches.length, files: matches }));
25093
+ }
25094
+ var globTool = (0, import_langchain7.tool)(
25095
+ async ({ pattern, cwd, maxResults, includeHidden }) => globFiles(pattern, cwd, maxResults, includeHidden),
25096
+ {
25097
+ name: "glob_files",
25098
+ description: "\u6309 glob \u6A21\u5F0F\u67E5\u627E\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u4E0B\u7684\u6587\u4EF6\uFF0C\u4F8B\u5982 **/*.ts\u3001src/**/*.tsx\u3002\u9ED8\u8BA4\u5FFD\u7565\u9690\u85CF\u76EE\u5F55\u3001node_modules\u3001dist\u3001.git\u3002",
25099
+ schema: external_exports.object({
25100
+ pattern: external_exports.string().describe("glob \u6587\u4EF6\u5339\u914D\u6A21\u5F0F\uFF0C\u4F8B\u5982 **/*.ts \u6216 src/**/*.tsx"),
25101
+ cwd: external_exports.string().optional().describe("\u641C\u7D22\u6839\u76EE\u5F55\uFF0C\u9ED8\u8BA4\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55"),
25102
+ maxResults: external_exports.number().default(200).describe("\u6700\u5927\u8FD4\u56DE\u6570\u91CF"),
25103
+ includeHidden: external_exports.boolean().default(false).describe("\u662F\u5426\u5305\u542B\u9690\u85CF\u6587\u4EF6\u6216\u9690\u85CF\u76EE\u5F55")
25104
+ })
25105
+ }
25106
+ );
25107
+
25108
+ // src/agent/tools/grep.ts
25109
+ var import_fs_extra13 = __toESM(require("fs-extra"));
25110
+ var import_path13 = __toESM(require("path"));
25111
+ var import_langchain8 = require("langchain");
25112
+ async function grepFiles(query, cwd, includePattern = "**/*", isRegexp = false, maxResults = 100, includeHidden = false) {
25113
+ const rootDir = resolveWorkspacePath(cwd || ".");
25114
+ const matcher = isRegexp ? new RegExp(query, "i") : null;
25115
+ const files = await walkFiles(rootDir, { includeHidden, maxFiles: Math.max(maxResults * 50, 1e3) });
25116
+ const matches = [];
25117
+ for (const file2 of files) {
25118
+ if (matches.length >= maxResults) break;
25119
+ const relativePath = normalizePathForMatch(import_path13.default.relative(rootDir, file2));
25120
+ if (!matchesGlob(relativePath, includePattern) || !isProbablyTextFile(file2)) {
25121
+ continue;
25122
+ }
25123
+ const content = await import_fs_extra13.default.readFile(file2, "utf-8").catch(() => "");
25124
+ const lines = content.split(/\r?\n/);
25125
+ for (let index = 0; index < lines.length; index++) {
25126
+ const line = lines[index];
25127
+ const ok = matcher ? matcher.test(line) : line.toLowerCase().includes(query.toLowerCase());
25128
+ if (ok) {
25129
+ matches.push({ filePath: relativePath, line: index + 1, text: line.trim() });
25130
+ if (matches.length >= maxResults) break;
25131
+ }
25132
+ }
25133
+ }
25134
+ return truncateOutput(formatJson({ cwd: rootDir, query, includePattern, count: matches.length, matches }));
25135
+ }
25136
+ var grepTool = (0, import_langchain8.tool)(
25137
+ async ({ query, cwd, includePattern, isRegexp, maxResults, includeHidden }) => grepFiles(query, cwd, includePattern, isRegexp, maxResults, includeHidden),
25138
+ {
25139
+ name: "grep_files",
25140
+ description: "\u5728\u6587\u672C\u6587\u4EF6\u4E2D\u641C\u7D22\u5185\u5BB9\uFF0C\u652F\u6301\u666E\u901A\u5B57\u7B26\u4E32\u6216\u6B63\u5219\u8868\u8FBE\u5F0F\uFF0C\u53EF\u7528 includePattern \u9650\u5B9A\u6587\u4EF6\u8303\u56F4\u3002",
25141
+ schema: external_exports.object({
25142
+ query: external_exports.string().describe("\u8981\u641C\u7D22\u7684\u5B57\u7B26\u4E32\u6216\u6B63\u5219\u8868\u8FBE\u5F0F"),
25143
+ cwd: external_exports.string().optional().describe("\u641C\u7D22\u6839\u76EE\u5F55\uFF0C\u9ED8\u8BA4\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55"),
25144
+ includePattern: external_exports.string().default("**/*").describe("\u9650\u5B9A\u641C\u7D22\u6587\u4EF6\u7684 glob \u6A21\u5F0F\uFF0C\u4F8B\u5982 src/**/*.ts"),
25145
+ isRegexp: external_exports.boolean().default(false).describe("query \u662F\u5426\u4E3A\u6B63\u5219\u8868\u8FBE\u5F0F"),
25146
+ maxResults: external_exports.number().default(100).describe("\u6700\u5927\u8FD4\u56DE\u5339\u914D\u6570\u91CF"),
25147
+ includeHidden: external_exports.boolean().default(false).describe("\u662F\u5426\u5305\u542B\u9690\u85CF\u6587\u4EF6\u6216\u9690\u85CF\u76EE\u5F55")
25148
+ })
25149
+ }
25150
+ );
25151
+
25152
+ // src/agent/tools/question.ts
25153
+ var import_inquirer2 = __toESM(require("inquirer"));
25154
+ var import_langchain9 = require("langchain");
25155
+ async function askQuestion(question, type = "input", choices = []) {
25156
+ const promptType = type === "select" ? "list" : type;
25157
+ const answer = await import_inquirer2.default.prompt([
25158
+ {
25159
+ name: "value",
25160
+ type: promptType,
25161
+ message: question,
25162
+ choices: type === "select" ? choices : void 0
25163
+ }
25164
+ ]);
25165
+ const value = answer["value"];
25166
+ return typeof value === "string" ? value : JSON.stringify(value);
22015
25167
  }
25168
+ var questionTool = (0, import_langchain9.tool)(
25169
+ async ({ question, type, choices }) => askQuestion(question, type, choices),
25170
+ {
25171
+ name: "ask_question",
25172
+ description: "\u5F53\u7EE7\u7EED\u4EFB\u52A1\u5FC5\u987B\u83B7\u53D6\u7528\u6237\u6F84\u6E05\u3001\u786E\u8BA4\u6216\u9009\u62E9\u65F6\uFF0C\u5411\u7528\u6237\u53D1\u8D77\u547D\u4EE4\u884C\u63D0\u95EE\u5E76\u8FD4\u56DE\u7B54\u6848\u3002\u4E0D\u8981\u8BE2\u95EE\u5BC6\u7801\u3001\u5BC6\u94A5\u7B49\u654F\u611F\u4FE1\u606F\u3002",
25173
+ schema: external_exports.object({
25174
+ question: external_exports.string().describe("\u8981\u8BE2\u95EE\u7528\u6237\u7684\u95EE\u9898"),
25175
+ type: external_exports.enum(["input", "confirm", "select"]).default("input").describe("\u95EE\u9898\u7C7B\u578B\uFF1Ainput \u6587\u672C\u8F93\u5165\u3001confirm \u786E\u8BA4\u3001select \u5355\u9009"),
25176
+ choices: external_exports.array(external_exports.string()).default([]).describe("select \u5355\u9009\u9879\u5217\u8868\uFF1B\u975E select \u7C7B\u578B\u53EF\u4E3A\u7A7A")
25177
+ })
25178
+ }
25179
+ );
25180
+
25181
+ // src/agent/tools/read.ts
25182
+ var import_fs_extra14 = __toESM(require("fs-extra"));
25183
+ var import_iconv_lite2 = __toESM(require("iconv-lite"));
25184
+ var import_langchain10 = require("langchain");
25185
+ async function readFile2(filePath, startLine = 1, endLine = -1, encoding) {
25186
+ const absPath = resolveWorkspacePath(filePath);
25187
+ if (!await import_fs_extra14.default.pathExists(absPath)) {
25188
+ return `Read error: \u6587\u4EF6\u4E0D\u5B58\u5728 ${absPath}`;
25189
+ }
25190
+ const stat = await import_fs_extra14.default.stat(absPath);
25191
+ if (!stat.isFile()) {
25192
+ return `Read error: \u8DEF\u5F84\u4E0D\u662F\u6587\u4EF6 ${absPath}`;
25193
+ }
25194
+ const buffer = await import_fs_extra14.default.readFile(absPath);
25195
+ const targetEncoding = encoding || getEncoding() || "utf-8";
25196
+ const content = import_iconv_lite2.default.decode(buffer, targetEncoding === "auto" ? "utf-8" : targetEncoding);
25197
+ const lines = content.split(/\r?\n/);
25198
+ const safeStart = Math.max(1, startLine || 1);
25199
+ const safeEnd = endLine && endLine > 0 ? Math.min(endLine, lines.length) : lines.length;
25200
+ if (safeStart > safeEnd) {
25201
+ return `Read error: \u884C\u53F7\u8303\u56F4\u65E0\u6548\uFF0C\u6587\u4EF6\u5171 ${lines.length} \u884C`;
25202
+ }
25203
+ const selected = lines.slice(safeStart - 1, safeEnd).map((line, index) => `${safeStart + index}: ${line}`).join("\n");
25204
+ return truncateOutput(formatJson({ filePath: absPath, totalLines: lines.length, startLine: safeStart, endLine: safeEnd, content: selected }));
25205
+ }
25206
+ var readFileTool = (0, import_langchain10.tool)(
25207
+ async ({ filePath, startLine, endLine, encoding }) => readFile2(filePath, startLine, endLine, encoding),
25208
+ {
25209
+ name: "read_file",
25210
+ description: "\u8BFB\u53D6\u672C\u5730\u6587\u672C\u6587\u4EF6\u5185\u5BB9\u3002\u652F\u6301\u7EDD\u5BF9\u8DEF\u5F84\u6216\u76F8\u5BF9\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u7684\u8DEF\u5F84\uFF0C\u53EF\u6307\u5B9A\u8D77\u6B62\u884C\u53F7\uFF1B\u8FD4\u56DE\u5E26\u884C\u53F7\u7684\u5185\u5BB9\u3002",
25211
+ schema: external_exports.object({
25212
+ filePath: external_exports.string().describe("\u8981\u8BFB\u53D6\u7684\u6587\u4EF6\u8DEF\u5F84\uFF0C\u652F\u6301\u7EDD\u5BF9\u8DEF\u5F84\u6216\u76F8\u5BF9\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u7684\u8DEF\u5F84"),
25213
+ startLine: external_exports.number().default(1).describe("\u8D77\u59CB\u884C\u53F7\uFF0C\u9ED8\u8BA4 1"),
25214
+ endLine: external_exports.number().default(-1).describe("\u7ED3\u675F\u884C\u53F7\uFF0C-1 \u8868\u793A\u8BFB\u53D6\u5230\u6587\u4EF6\u672B\u5C3E"),
25215
+ encoding: external_exports.string().optional().describe("\u6587\u4EF6\u7F16\u7801\uFF0C\u4F8B\u5982 utf-8\u3001gbk\uFF1B\u4E0D\u586B\u5219\u4F7F\u7528\u5168\u5C40\u7F16\u7801\u914D\u7F6E")
25216
+ })
25217
+ }
25218
+ );
25219
+
25220
+ // src/agent/tools/semanticMemory.ts
25221
+ var import_fs_extra15 = __toESM(require("fs-extra"));
25222
+ var import_path14 = __toESM(require("path"));
25223
+ var import_langchain11 = require("langchain");
25224
+ var DEFAULT_MEMORY_MARKDOWN = `# \u7528\u6237\u8BED\u4E49\u8BB0\u5FC6
25225
+
25226
+ > \u8BE5\u6587\u4EF6\u7531\u8BED\u4E49\u8BB0\u5FC6\u5DE5\u5177\u7EF4\u62A4\u3002\u4EC5\u8BB0\u5F55\u53EF\u957F\u671F\u590D\u7528\u7684\u7528\u6237\u4FE1\u606F\u3001\u4E60\u60EF\u548C\u504F\u597D\uFF1B\u4E0D\u8981\u8BB0\u5F55\u5BC6\u7801\u3001\u5BC6\u94A5\u3001\u4EE4\u724C\u7B49\u654F\u611F\u4FE1\u606F\u3002
25227
+
25228
+ ## \u7528\u6237\u79F0\u547C
25229
+
25230
+ ## \u64CD\u4F5C\u4E60\u60EF
25231
+
25232
+ ## \u7F16\u7801\u4E60\u60EF
25233
+
25234
+ ## \u4E2A\u4EBA\u504F\u597D
25235
+
25236
+ ## \u5176\u4ED6\u957F\u671F\u8BB0\u5FC6
25237
+ `;
25238
+ function getMemoryFilePath(runtimeMemoryFilePath) {
25239
+ return typeof runtimeMemoryFilePath === "string" && runtimeMemoryFilePath.trim() ? runtimeMemoryFilePath : void 0;
25240
+ }
25241
+ async function readSemanticMemory(memoryFilePath) {
25242
+ if (!memoryFilePath) {
25243
+ return "Semantic memory error: \u5F53\u524D\u8FD0\u884C\u4E0A\u4E0B\u6587\u672A\u63D0\u4F9B memoryFilePath\uFF0C\u65E0\u6CD5\u8BFB\u53D6\u7528\u6237\u8BED\u4E49\u8BB0\u5FC6";
25244
+ }
25245
+ if (!await import_fs_extra15.default.pathExists(memoryFilePath)) {
25246
+ return DEFAULT_MEMORY_MARKDOWN;
25247
+ }
25248
+ return import_fs_extra15.default.readFile(memoryFilePath, "utf-8");
25249
+ }
25250
+ async function updateSemanticMemory(memoryFilePath, content) {
25251
+ if (!memoryFilePath) {
25252
+ return "Semantic memory error: \u5F53\u524D\u8FD0\u884C\u4E0A\u4E0B\u6587\u672A\u63D0\u4F9B memoryFilePath\uFF0C\u65E0\u6CD5\u66F4\u65B0\u7528\u6237\u8BED\u4E49\u8BB0\u5FC6";
25253
+ }
25254
+ await import_fs_extra15.default.ensureDir(import_path14.default.dirname(memoryFilePath));
25255
+ await import_fs_extra15.default.writeFile(memoryFilePath, `${content.trim()}
25256
+ `, "utf-8");
25257
+ return `\u5DF2\u66F4\u65B0\u7528\u6237\u8BED\u4E49\u8BB0\u5FC6: ${memoryFilePath}`;
25258
+ }
25259
+ var readSemanticMemoryTool = (0, import_langchain11.tool)(
25260
+ async (_input, runtime) => {
25261
+ return readSemanticMemory(getMemoryFilePath(runtime.context?.memoryFilePath));
25262
+ },
25263
+ {
25264
+ name: "read_user_semantic_memory",
25265
+ description: "\u8BFB\u53D6\u5F53\u524D\u7528\u6237\u8BED\u4E49\u8BB0\u5FC6 Markdown \u6587\u4EF6\u3002\u51C6\u5907\u65B0\u589E\u3001\u4FEE\u6B63\u6216\u5408\u5E76\u7528\u6237\u957F\u671F\u504F\u597D\u524D\uFF0C\u5E94\u5148\u8C03\u7528\u672C\u5DE5\u5177\u8BFB\u53D6\u73B0\u6709\u5185\u5BB9\uFF0C\u907F\u514D\u91CD\u590D\u548C\u8986\u76D6\u5DF2\u6709\u4FE1\u606F\u3002\u82E5\u6587\u4EF6\u4E0D\u5B58\u5728\uFF0C\u4F1A\u8FD4\u56DE\u63A8\u8350\u7684 Markdown \u6A21\u677F\u3002",
25266
+ schema: external_exports.object({})
25267
+ }
25268
+ );
25269
+ var updateSemanticMemoryTool = (0, import_langchain11.tool)(
25270
+ async ({ content }, runtime) => {
25271
+ return updateSemanticMemory(getMemoryFilePath(runtime.context?.memoryFilePath), content);
25272
+ },
25273
+ {
25274
+ name: "update_user_semantic_memory",
25275
+ description: "\u8986\u76D6\u66F4\u65B0\u5F53\u524D\u7528\u6237\u8BED\u4E49\u8BB0\u5FC6 Markdown \u6587\u4EF6\u3002content \u5FC5\u987B\u662F\u5B8C\u6574\u7684 Markdown \u6587\u4EF6\u5185\u5BB9\uFF0C\u800C\u4E0D\u662F\u7247\u6BB5\u3002\u4EC5\u8BB0\u5F55\u660E\u786E\u3001\u7A33\u5B9A\u3001\u53EF\u957F\u671F\u590D\u7528\u7684\u4FE1\u606F\uFF0C\u4F8B\u5982\u7528\u6237\u79F0\u547C\u3001\u64CD\u4F5C\u4E60\u60EF\u3001\u7F16\u7801\u4E60\u60EF\u3001\u4E2A\u4EBA\u504F\u597D\u7B49\uFF1B\u4E0D\u8981\u8BB0\u5F55\u4E00\u6B21\u6027\u4EFB\u52A1\u4FE1\u606F\u3001\u4E34\u65F6\u4E0A\u4E0B\u6587\u3001\u63A8\u6D4B\u5185\u5BB9\u3001\u5BC6\u7801\u3001\u5BC6\u94A5\u3001\u4EE4\u724C\u3001\u9690\u79C1\u654F\u611F\u4FE1\u606F\u3002\u66F4\u65B0\u524D\u5E94\u5148\u8C03\u7528 read_user_semantic_memory \u8BFB\u53D6\u73B0\u6709\u5185\u5BB9\uFF0C\u7136\u540E\u5728\u4FDD\u7559\u5DF2\u6709\u6709\u6548\u8BB0\u5FC6\u7684\u57FA\u7840\u4E0A\u5408\u5E76\u65B0\u4FE1\u606F\uFF0C\u6309 Markdown \u6807\u9898\u548C\u5217\u8868\u6574\u7406\uFF0C\u5E76\u81EA\u884C\u53BB\u91CD\u3002",
25276
+ schema: external_exports.object({
25277
+ content: external_exports.string().describe("\u5B8C\u6574\u7684\u7528\u6237\u8BED\u4E49\u8BB0\u5FC6 Markdown \u5185\u5BB9\uFF0C\u9700\u4FDD\u7559\u5E76\u5408\u5E76\u5DF2\u6709\u6709\u6548\u8BB0\u5FC6\uFF0C\u6309\u5206\u7C7B\u6807\u9898\u548C\u5217\u8868\u9879\u7EC4\u7EC7")
25278
+ })
25279
+ }
25280
+ );
25281
+ var semanticMemoryTools = [readSemanticMemoryTool, updateSemanticMemoryTool];
22016
25282
 
22017
25283
  // src/cli/cli-utils/TaskQueue.ts
22018
25284
  var import_crypto3 = require("crypto");
22019
25285
  var import_dayjs = __toESM(require("dayjs"));
22020
- var import_fs_extra10 = __toESM(require("fs-extra"));
25286
+ var import_fs_extra16 = __toESM(require("fs-extra"));
22021
25287
  var TaskQueue = class {
22022
25288
  taskFilePath;
22023
25289
  constructor(agent) {
@@ -22034,11 +25300,11 @@ var TaskQueue = class {
22034
25300
  this.updateTasks(taskList);
22035
25301
  }
22036
25302
  loadTasks() {
22037
- const tasks = import_fs_extra10.default.readJSONSync(this.taskFilePath, { throws: false }) || [];
25303
+ const tasks = import_fs_extra16.default.readJSONSync(this.taskFilePath, { throws: false }) || [];
22038
25304
  return tasks;
22039
25305
  }
22040
25306
  updateTasks(tasks) {
22041
- import_fs_extra10.default.writeJSONSync(this.taskFilePath, tasks);
25307
+ import_fs_extra16.default.writeJSONSync(this.taskFilePath, tasks);
22042
25308
  }
22043
25309
  clearTasks() {
22044
25310
  this.updateTasks([]);
@@ -22061,6 +25327,161 @@ var TaskQueue = class {
22061
25327
  }
22062
25328
  };
22063
25329
 
25330
+ // src/agent/tools/task.ts
25331
+ var import_langchain12 = require("langchain");
25332
+ function getCurrentTaskQueue(agentId) {
25333
+ return agentId ? new TaskQueue(agentId) : null;
25334
+ }
25335
+ function manageTaskQueue(agentId, action, task, index) {
25336
+ const queue = getCurrentTaskQueue(agentId);
25337
+ if (!queue) {
25338
+ return "Task error: \u672A\u627E\u5230\u5F53\u524D\u4F1A\u8BDD\uFF0C\u8BF7\u5148\u521B\u5EFA agent \u4F1A\u8BDD";
25339
+ }
25340
+ if (action === "list") {
25341
+ return formatJson({ tasks: queue.loadTasks() });
25342
+ }
25343
+ if (action === "add") {
25344
+ if (!task?.trim()) {
25345
+ return "Task error: \u6DFB\u52A0\u4EFB\u52A1\u65F6 task \u4E0D\u80FD\u4E3A\u7A7A";
25346
+ }
25347
+ queue.pushTask(task.trim());
25348
+ return `\u5DF2\u6DFB\u52A0\u4EFB\u52A1: ${task.trim()}`;
25349
+ }
25350
+ if (action === "delete") {
25351
+ const tasks = queue.loadTasks();
25352
+ const safeIndex = Number(index);
25353
+ if (!Number.isInteger(safeIndex) || safeIndex < 1 || safeIndex > tasks.length) {
25354
+ return `Task error: \u4EFB\u52A1\u5E8F\u53F7\u65E0\u6548\uFF0C\u5F53\u524D\u4EFB\u52A1\u6570 ${tasks.length}`;
25355
+ }
25356
+ const removed = tasks[safeIndex - 1];
25357
+ queue.delTask(safeIndex - 1);
25358
+ return `\u5DF2\u5220\u9664\u4EFB\u52A1: [${removed.createTime}] ${removed.taskStr}`;
25359
+ }
25360
+ queue.clearTasks();
25361
+ return "\u5DF2\u6E05\u7A7A\u4EFB\u52A1\u961F\u5217";
25362
+ }
25363
+ var taskTool = (0, import_langchain12.tool)(
25364
+ async ({ action, task, index }, runtime) => {
25365
+ const agentId = runtime.context?.agentId || getAgentId();
25366
+ return manageTaskQueue(agentId, action, task, index);
25367
+ },
25368
+ {
25369
+ name: "manage_task_queue",
25370
+ description: "\u7BA1\u7406\u5F53\u524D agent \u4F1A\u8BDD\u4EFB\u52A1\u961F\u5217\uFF1A\u67E5\u770B\u3001\u6DFB\u52A0\u540E\u7EED\u4EFB\u52A1\u3001\u5220\u9664\u6307\u5B9A\u4EFB\u52A1\u6216\u6E05\u7A7A\u4EFB\u52A1\u3002\u6DFB\u52A0\u7684\u4EFB\u52A1\u4F1A\u5728\u5F53\u524D\u4EFB\u52A1\u7ED3\u675F\u540E\u7EE7\u7EED\u6267\u884C\u3002",
25371
+ schema: external_exports.object({
25372
+ action: external_exports.enum(["list", "add", "delete", "clear"]).describe("\u4EFB\u52A1\u961F\u5217\u64CD\u4F5C"),
25373
+ task: external_exports.string().optional().describe("action=add \u65F6\u8981\u6DFB\u52A0\u7684\u4EFB\u52A1\u5185\u5BB9"),
25374
+ index: external_exports.number().optional().describe("action=delete \u65F6\u8981\u5220\u9664\u7684\u4EFB\u52A1\u5E8F\u53F7\uFF0C\u4ECE 1 \u5F00\u59CB")
25375
+ })
25376
+ }
25377
+ );
25378
+
25379
+ // src/agent/tools/webfetch.ts
25380
+ var import_langchain13 = require("langchain");
25381
+ async function webFetch(url2, timeout = 3e4, maxLength = 6e4) {
25382
+ const controller = new AbortController();
25383
+ const timer = setTimeout(() => controller.abort(), timeout);
25384
+ try {
25385
+ const response = await fetch(url2, {
25386
+ method: "GET",
25387
+ headers: {
25388
+ "user-agent": "deepfish-ai/agent-tool",
25389
+ accept: "text/html,text/plain,application/json,application/xml,*/*"
25390
+ },
25391
+ signal: controller.signal
25392
+ });
25393
+ const contentType = response.headers.get("content-type") || "";
25394
+ const text = await response.text();
25395
+ return truncateOutput(
25396
+ JSON.stringify(
25397
+ {
25398
+ url: url2,
25399
+ status: response.status,
25400
+ ok: response.ok,
25401
+ contentType,
25402
+ body: text
25403
+ },
25404
+ null,
25405
+ 2
25406
+ ),
25407
+ maxLength
25408
+ );
25409
+ } catch (error51) {
25410
+ const message = error51 instanceof Error ? error51.message : String(error51);
25411
+ return `Web fetch error: ${message}`;
25412
+ } finally {
25413
+ clearTimeout(timer);
25414
+ }
25415
+ }
25416
+ var webFetchTool = (0, import_langchain13.tool)(
25417
+ async ({ url: url2, timeout, maxLength }) => webFetch(url2, timeout, maxLength),
25418
+ {
25419
+ name: "web_fetch",
25420
+ description: "\u901A\u8FC7 HTTP GET \u83B7\u53D6\u7F51\u9875\u3001\u63A5\u53E3\u6216\u8FDC\u7A0B\u6587\u672C\u5185\u5BB9\uFF0C\u5E76\u8FD4\u56DE\u72B6\u6001\u7801\u3001content-type \u548C\u54CD\u5E94\u6B63\u6587\u3002",
25421
+ schema: external_exports.object({
25422
+ url: external_exports.string().url().describe("\u8981\u8BF7\u6C42\u7684\u5B8C\u6574 URL\uFF0C\u4F8B\u5982 https://example.com"),
25423
+ timeout: external_exports.number().default(3e4).describe("\u8BF7\u6C42\u8D85\u65F6\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09"),
25424
+ maxLength: external_exports.number().default(6e4).describe("\u6700\u5927\u8FD4\u56DE\u5B57\u7B26\u6570\uFF0C\u8D85\u51FA\u4F1A\u622A\u65AD")
25425
+ })
25426
+ }
25427
+ );
25428
+
25429
+ // src/agent/tools/write.ts
25430
+ var import_fs_extra17 = __toESM(require("fs-extra"));
25431
+ var import_path15 = __toESM(require("path"));
25432
+ var import_langchain14 = require("langchain");
25433
+ async function writeFile2(filePath, content, mode = "overwrite") {
25434
+ const absPath = resolveWorkspacePath(filePath);
25435
+ const exists = await import_fs_extra17.default.pathExists(absPath);
25436
+ if (mode === "create" && exists) {
25437
+ return `Write error: \u6587\u4EF6\u5DF2\u5B58\u5728\uFF0Ccreate \u6A21\u5F0F\u4E0D\u4F1A\u8986\u76D6 ${absPath}`;
25438
+ }
25439
+ await import_fs_extra17.default.ensureDir(import_path15.default.dirname(absPath));
25440
+ if (mode === "append") {
25441
+ await import_fs_extra17.default.appendFile(absPath, content, "utf-8");
25442
+ return `\u5DF2\u8FFD\u52A0\u5199\u5165\u6587\u4EF6: ${absPath}`;
25443
+ }
25444
+ await import_fs_extra17.default.writeFile(absPath, content, "utf-8");
25445
+ return `${exists ? "\u5DF2\u8986\u76D6\u5199\u5165\u6587\u4EF6" : "\u5DF2\u521B\u5EFA\u6587\u4EF6"}: ${absPath}`;
25446
+ }
25447
+ var writeFileTool = (0, import_langchain14.tool)(
25448
+ async ({ filePath, content, mode }) => writeFile2(filePath, content, mode),
25449
+ {
25450
+ name: "write_file",
25451
+ description: "\u5411\u672C\u5730\u6587\u4EF6\u5199\u5165\u6587\u672C\u5185\u5BB9\u3002\u53EF\u521B\u5EFA\u65B0\u6587\u4EF6\u3001\u8986\u76D6\u5DF2\u6709\u6587\u4EF6\u6216\u8FFD\u52A0\u5185\u5BB9\uFF0C\u4F1A\u81EA\u52A8\u521B\u5EFA\u7236\u76EE\u5F55\u3002",
25452
+ schema: external_exports.object({
25453
+ filePath: external_exports.string().describe("\u76EE\u6807\u6587\u4EF6\u8DEF\u5F84\uFF0C\u652F\u6301\u7EDD\u5BF9\u8DEF\u5F84\u6216\u76F8\u5BF9\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u7684\u8DEF\u5F84"),
25454
+ content: external_exports.string().describe("\u8981\u5199\u5165\u7684\u5B8C\u6574\u6587\u672C\u5185\u5BB9"),
25455
+ mode: external_exports.enum(["overwrite", "append", "create"]).default("overwrite").describe("\u5199\u5165\u6A21\u5F0F\uFF1Aoverwrite \u8986\u76D6\u3001append \u8FFD\u52A0\u3001create \u4EC5\u65B0\u5EFA")
25456
+ })
25457
+ }
25458
+ );
25459
+
25460
+ // src/agent/tools/index.ts
25461
+ var builtinTools = [
25462
+ taskTool,
25463
+ executeCommandTool,
25464
+ readFileTool,
25465
+ editFileTool,
25466
+ writeFileTool,
25467
+ globTool,
25468
+ grepTool,
25469
+ questionTool,
25470
+ webFetchTool,
25471
+ ...packageTools,
25472
+ ...semanticMemoryTools,
25473
+ ...learnTools
25474
+ ];
25475
+ async function getTools() {
25476
+ return [...builtinTools, ...await scanUserTools(), ...await scanUserMcp()];
25477
+ }
25478
+
25479
+ // src/agent/skills/index.ts
25480
+ var import_path16 = __toESM(require("path"));
25481
+ function getSkills() {
25482
+ return [...getRegisteredSkills(), import_path16.default.join(__dirname, "./view-learn-cache.md")];
25483
+ }
25484
+
22064
25485
  // src/agent/AIAgent/index.ts
22065
25486
  var import_os3 = __toESM(require("os"));
22066
25487
  var AIAgent = class extends import_eventemitter_super.EventEmitterSuper {
@@ -22078,8 +25499,10 @@ var AIAgent = class extends import_eventemitter_super.EventEmitterSuper {
22078
25499
  memoryFilePath = "";
22079
25500
  sessionDirPath = "";
22080
25501
  userStorePath = "";
25502
+ agentRulesPath = "";
22081
25503
  roomClient = null;
22082
25504
  taskQueue = {};
25505
+ isPrintThinking = true;
22083
25506
  constructor(opt) {
22084
25507
  super();
22085
25508
  this.id = opt.id || `agent-${Date.now()}`;
@@ -22087,6 +25510,9 @@ var AIAgent = class extends import_eventemitter_super.EventEmitterSuper {
22087
25510
  this.workspace = opt.workspace;
22088
25511
  this.memoryFilePath = opt.memoryFilePath;
22089
25512
  this.sessionDirPath = opt.sessionDirPath;
25513
+ this.userStorePath = opt.userStorePath;
25514
+ this.agentRulesPath = opt.agentRulesPath;
25515
+ this.isPrintThinking = opt.isPrintThinking;
22090
25516
  this.opt = opt;
22091
25517
  }
22092
25518
  async init() {
@@ -22098,73 +25524,110 @@ var AIAgent = class extends import_eventemitter_super.EventEmitterSuper {
22098
25524
  });
22099
25525
  const contextSchema = external_exports.object({
22100
25526
  agent_name: external_exports.string(),
22101
- encoding: external_exports.string()
25527
+ encoding: external_exports.string(),
25528
+ skills: external_exports.array(external_exports.string()).optional(),
25529
+ memoryFilePath: external_exports.string().optional(),
25530
+ agentId: external_exports.string().optional()
22102
25531
  });
22103
- const agent = (0, import_deepagents.createDeepAgent)({
25532
+ const agent = (0, import_langchain15.createAgent)({
22104
25533
  model,
22105
25534
  checkpointer,
22106
- backend: new import_deepagents.FilesystemBackend({
22107
- rootDir: this.workspace,
22108
- virtualMode: false
22109
- }),
22110
25535
  tools: this.tools,
22111
- skills: this.skills,
22112
25536
  contextSchema,
22113
25537
  middleware: [
22114
- createAgentEventMiddleware(this)
25538
+ createAgentEventMiddleware(this),
25539
+ (0, import_langchain15.summarizationMiddleware)({
25540
+ model,
25541
+ trigger: { tokens: this.opt.modelOpt.maxContextLength || 1e5 },
25542
+ keep: { messages: 50 }
25543
+ }),
25544
+ (0, import_langchain15.humanInTheLoopMiddleware)({
25545
+ interruptOn: {
25546
+ install_package: {
25547
+ allowedDecisions: ["approve", "reject"]
25548
+ },
25549
+ readEmailTool: false
25550
+ }
25551
+ }),
25552
+ (0, import_langchain15.todoListMiddleware)(),
25553
+ (0, import_deepagents.createPatchToolCallsMiddleware)(),
25554
+ (0, import_deepagents.createSubAgentMiddleware)({
25555
+ defaultModel: model,
25556
+ subagents: [
25557
+ {
25558
+ name: "subagent",
25559
+ description: "This subagent can execute sub tasks.",
25560
+ systemPrompt: subSystemPrompt(this.workspace, import_os3.default.platform(), this.skills),
25561
+ tools: this.tools,
25562
+ model,
25563
+ middleware: []
25564
+ }
25565
+ ]
25566
+ })
22115
25567
  ],
22116
- memory: [this.memoryFilePath],
22117
- systemPrompt: systemPrompt(this.workspace, import_os3.default.platform())
25568
+ systemPrompt: systemPrompt(this.workspace, import_os3.default.platform(), this.skills, this.memoryFilePath, this.agentRulesPath)
22118
25569
  });
22119
25570
  this.agent = agent;
22120
- this.taskQueue = new TaskQueue(this);
25571
+ this.taskQueue = new TaskQueue(this.id);
22121
25572
  this.initEvents();
22122
25573
  }
22123
25574
  async execute(input) {
22124
- const humanMessage = new import_langchain6.HumanMessage(input);
25575
+ const humanMessage = new import_langchain15.HumanMessage(input);
22125
25576
  this.messages.push(humanMessage);
22126
25577
  const stream = await this.agent.stream(
22127
25578
  { messages: this.messages },
22128
25579
  {
22129
25580
  streamMode: ["messages"],
25581
+ recursionLimit: 2e3,
22130
25582
  subgraphs: true,
22131
25583
  configurable: { thread_id: this.id },
22132
- context: { agent_name: "deepfish", encoding: this.opt.encoding }
25584
+ context: { agent_name: "deepfish", encoding: this.opt.encoding, skills: this.skills, memoryFilePath: this.memoryFilePath, agentId: this.id }
22133
25585
  }
22134
25586
  );
22135
25587
  for await (const [_namespace, mode, data] of stream) {
22136
25588
  if (mode === "messages") {
22137
- this.emit("STREAM_CONTENT_OUTPUT" /* STREAM_CONTENT_OUTPUT */, data[0].content);
25589
+ const message = data[0].additional_kwargs.reasoning_content;
25590
+ this.emit("STREAM_CONTENT_OUTPUT" /* STREAM_CONTENT_OUTPUT */, message);
22138
25591
  }
22139
25592
  }
25593
+ const newTask = this.taskQueue.getTask();
25594
+ if (newTask) {
25595
+ log(`[\u4EFB\u52A1\u961F\u5217] \u53D1\u73B0\u65B0\u4EFB\u52A1\uFF0C\u5373\u5C06\u6267\u884C: ${newTask.taskStr}`, "#7fded1");
25596
+ await this.execute(newTask.taskStr);
25597
+ }
22140
25598
  }
22141
25599
  initEvents() {
22142
25600
  const thinking = new Thinking();
22143
25601
  this.on("TASK_BEFORE" /* TASK_BEFORE */, () => {
22144
- thinking.init();
22145
25602
  });
22146
25603
  this.on("TASK_AFTER" /* TASK_AFTER */, (msg) => {
22147
- thinking.stop();
22148
- const newTask = this.taskQueue.getTask();
22149
- if (newTask) {
22150
- log(`[\u4EFB\u52A1\u961F\u5217] \u53D1\u73B0\u65B0\u4EFB\u52A1\uFF0C\u5373\u5C06\u6267\u884C: ${newTask.taskStr}`, "#7fded1");
22151
- this.execute(newTask.taskStr);
22152
- }
25604
+ logInfo(msg);
22153
25605
  });
22154
25606
  this.on("MODEL_BEFORE" /* MODEL_BEFORE */, () => {
22155
25607
  });
22156
25608
  this.on("MODEL_AFTER" /* MODEL_AFTER */, () => {
25609
+ if (this.isPrintThinking) {
25610
+ thinking.stop();
25611
+ }
22157
25612
  streamOutput("\n");
22158
25613
  });
22159
25614
  this.on("MODEL_ERROR" /* MODEL_ERROR */, (error51) => {
25615
+ if (this.isPrintThinking) {
25616
+ thinking.stop();
25617
+ }
22160
25618
  logError(error51?.message + "\n" + error51?.stack);
22161
25619
  });
22162
25620
  this.on("STREAM_CONTENT_OUTPUT" /* STREAM_CONTENT_OUTPUT */, (content) => {
22163
- thinking.setStop(content);
22164
- if (!thinking.isThinking) {
22165
- if (typeof content === "string") {
25621
+ if (this.isPrintThinking) {
25622
+ if (content && typeof content === "string") {
22166
25623
  streamOutput(content, "#f2c97d");
22167
25624
  }
25625
+ } else {
25626
+ if (content && typeof content === "string") {
25627
+ thinking.start();
25628
+ } else {
25629
+ thinking.stop();
25630
+ }
22168
25631
  }
22169
25632
  });
22170
25633
  this.on("COMPRESS_MESSAGES_BEFORE" /* COMPRESS_MESSAGES_BEFORE */, (_currentLength) => {
@@ -22174,7 +25637,6 @@ var AIAgent = class extends import_eventemitter_super.EventEmitterSuper {
22174
25637
  this.on("NEW_MESSAGE" /* NEW_MESSAGE */, (_msg) => {
22175
25638
  });
22176
25639
  this.on("USE_TOOL_BEFORE" /* USE_TOOL_BEFORE */, (_toolId, funcName, _funcArgs) => {
22177
- thinking.stop();
22178
25640
  log(`[\u8C03\u7528\u5DE5\u5177] ${funcName}`, "#c2a654");
22179
25641
  });
22180
25642
  this.on("USE_TOOL_RETURN" /* USE_TOOL_RETURN */, (_toolId, funcName, toolContent) => {
@@ -22279,12 +25741,12 @@ var AgentRoomClient = class {
22279
25741
  };
22280
25742
 
22281
25743
  // src/cli/cli-core/serve.ts
22282
- var import_path12 = __toESM(require("path"));
25744
+ var import_path17 = __toESM(require("path"));
22283
25745
  var import_pm2 = __toESM(require("pm2"));
22284
25746
  var PM2_APP_NAME = "deepfish-ai-server";
22285
25747
  function getPm2Config() {
22286
25748
  const port = getServePort();
22287
- const serverScript = import_path12.default.join(getCodePath(), "dist/serve/pm2-server");
25749
+ const serverScript = import_path17.default.join(getCodePath(), "dist/serve/pm2-server");
22288
25750
  return {
22289
25751
  name: PM2_APP_NAME,
22290
25752
  script: serverScript,
@@ -22296,8 +25758,8 @@ function getPm2Config() {
22296
25758
  autorestart: true,
22297
25759
  watch: false,
22298
25760
  max_memory_restart: "1G",
22299
- error_file: import_path12.default.join(getCodePath(), "logs", "pm2-error.log"),
22300
- out_file: import_path12.default.join(getCodePath(), "logs", "pm2-out.log"),
25761
+ error_file: import_path17.default.join(getCodePath(), "logs", "pm2-error.log"),
25762
+ out_file: import_path17.default.join(getCodePath(), "logs", "pm2-out.log"),
22301
25763
  log_date_format: "YYYY-MM-DD HH:mm:ss Z"
22302
25764
  };
22303
25765
  }
@@ -22429,13 +25891,16 @@ async function initAgent(config2, skills) {
22429
25891
  memoryFilePath: userPath.memory,
22430
25892
  userStorePath: userPath.userStore,
22431
25893
  sessionDirPath: getSessionDirPath(id),
25894
+ agentRulesPath: userPath.agentRules,
22432
25895
  maxBlockFileSize: config2.maxBlockFileSize,
22433
25896
  // Max chunk file size in KB; files exceeding this size need to be processed in chunks
22434
25897
  encoding: config2.encoding,
22435
25898
  // CLI encoding format, can be set to utf-8, gbk, etc., or left empty for auto-detection
22436
25899
  maxSubAgentCount: config2.maxSubAgentCount,
22437
25900
  // Maximum parallel sub-agent execution count, -1 means unlimited
22438
- skills
25901
+ skills,
25902
+ isPrintThinking: config2.isPrintThinking
25903
+ // Whether to print intermediate information during AI thinking, default is true
22439
25904
  });
22440
25905
  await agent.init();
22441
25906
  return agent;
@@ -22528,20 +25993,20 @@ function removeSessionById(agentId) {
22528
25993
  return;
22529
25994
  }
22530
25995
  const sessionDir = getSessionPath(agentId);
22531
- import_fs_extra11.default.removeSync(sessionDir);
25996
+ import_fs_extra18.default.removeSync(sessionDir);
22532
25997
  const sessionsPath = getSessionsPath();
22533
- const sessionsFilePath = import_path13.default.join(sessionsPath, "sessions.json");
22534
- if (!import_fs_extra11.default.pathExistsSync(sessionsFilePath)) {
25998
+ const sessionsFilePath = import_path18.default.join(sessionsPath, "sessions.json");
25999
+ if (!import_fs_extra18.default.pathExistsSync(sessionsFilePath)) {
22535
26000
  logSuccess("Current session history cleared");
22536
26001
  return;
22537
26002
  }
22538
- const content = import_fs_extra11.default.readFileSync(sessionsFilePath, "utf-8");
26003
+ const content = import_fs_extra18.default.readFileSync(sessionsFilePath, "utf-8");
22539
26004
  const parsed = JSON.parse(content);
22540
26005
  const sessions = Array.isArray(parsed) ? parsed : [];
22541
26006
  const existingSessionIndex = sessions.findIndex((s) => s.id === agentId);
22542
26007
  if (existingSessionIndex !== -1) {
22543
26008
  sessions.splice(existingSessionIndex, 1);
22544
- import_fs_extra11.default.writeFileSync(sessionsFilePath, JSON.stringify(sessions, null, 2), "utf-8");
26009
+ import_fs_extra18.default.writeFileSync(sessionsFilePath, JSON.stringify(sessions, null, 2), "utf-8");
22545
26010
  }
22546
26011
  logSuccess("Current session history cleared");
22547
26012
  }
@@ -22557,15 +26022,15 @@ function openSessionDir() {
22557
26022
  }
22558
26023
  function initSession() {
22559
26024
  const sessionsPath = getSessionsPath();
22560
- const sessionsFilePath = import_path13.default.join(sessionsPath, "sessions.json");
26025
+ const sessionsFilePath = import_path18.default.join(sessionsPath, "sessions.json");
22561
26026
  let sessions = [];
22562
- if (import_fs_extra11.default.pathExistsSync(sessionsFilePath)) {
22563
- const content = import_fs_extra11.default.readFileSync(sessionsFilePath, "utf-8");
26027
+ if (import_fs_extra18.default.pathExistsSync(sessionsFilePath)) {
26028
+ const content = import_fs_extra18.default.readFileSync(sessionsFilePath, "utf-8");
22564
26029
  const parsed = JSON.parse(content);
22565
26030
  sessions = Array.isArray(parsed) ? parsed : [];
22566
26031
  } else {
22567
- import_fs_extra11.default.ensureDirSync(sessionsPath);
22568
- import_fs_extra11.default.writeFileSync(sessionsFilePath, "[]", "utf-8");
26032
+ import_fs_extra18.default.ensureDirSync(sessionsPath);
26033
+ import_fs_extra18.default.writeFileSync(sessionsFilePath, "[]", "utf-8");
22569
26034
  }
22570
26035
  const workspace = getWorkspacePath();
22571
26036
  const existingSession = sessions.find((s) => s.workspace === workspace);
@@ -22576,23 +26041,23 @@ function initSession() {
22576
26041
  const agentId = (0, import_crypto4.randomUUID)();
22577
26042
  const newSession = {
22578
26043
  id: agentId,
22579
- name: import_path13.default.basename(workspace),
26044
+ name: import_path18.default.basename(workspace),
22580
26045
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
22581
26046
  updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
22582
26047
  workspace
22583
26048
  };
22584
26049
  sessions.push(newSession);
22585
- import_fs_extra11.default.writeFileSync(sessionsFilePath, JSON.stringify(sessions, null, 2), "utf-8");
26050
+ import_fs_extra18.default.writeFileSync(sessionsFilePath, JSON.stringify(sessions, null, 2), "utf-8");
22586
26051
  initSessionDir(newSession.id);
22587
26052
  return newSession;
22588
26053
  }
22589
26054
  function initSessionDir(agentId) {
22590
26055
  const sessionDir = getSessionPath(agentId);
22591
- import_fs_extra11.default.ensureDirSync(sessionDir);
26056
+ import_fs_extra18.default.ensureDirSync(sessionDir);
22592
26057
  const mainSessionPath = `${sessionDir}/main-session/`;
22593
26058
  const mainMsgQueuePath = `${sessionDir}/main-msg-queue.json`;
22594
- import_fs_extra11.default.ensureDirSync(mainSessionPath);
22595
- import_fs_extra11.default.ensureFileSync(mainMsgQueuePath);
26059
+ import_fs_extra18.default.ensureDirSync(mainSessionPath);
26060
+ import_fs_extra18.default.ensureFileSync(mainMsgQueuePath);
22596
26061
  }
22597
26062
  function _getCurrentAIConfig(config2) {
22598
26063
  const currentModelName = config2.currentModel;
@@ -22607,11 +26072,11 @@ function _getCurrentAIConfig(config2) {
22607
26072
  }
22608
26073
  function getAgentId() {
22609
26074
  const sessionsPath = getSessionsPath();
22610
- const sessionsFilePath = import_path13.default.join(sessionsPath, "sessions.json");
22611
- if (!import_fs_extra11.default.pathExistsSync(sessionsFilePath)) {
26075
+ const sessionsFilePath = import_path18.default.join(sessionsPath, "sessions.json");
26076
+ if (!import_fs_extra18.default.pathExistsSync(sessionsFilePath)) {
22612
26077
  return;
22613
26078
  }
22614
- const content = import_fs_extra11.default.readFileSync(sessionsFilePath, "utf-8");
26079
+ const content = import_fs_extra18.default.readFileSync(sessionsFilePath, "utf-8");
22615
26080
  const parsed = JSON.parse(content);
22616
26081
  const sessions = Array.isArray(parsed) ? parsed : [];
22617
26082
  const workspace = getWorkspacePath();
@@ -22639,12 +26104,12 @@ function handleSkillsLs() {
22639
26104
  async function handleSkillsAdd(name) {
22640
26105
  logInfo(`Adding skill: ${name}`);
22641
26106
  const workspace = getWorkspacePath();
22642
- const skillDir = import_path14.default.join(workspace, name);
22643
- if (!import_fs_extra12.default.existsSync(skillDir)) {
26107
+ const skillDir = import_path19.default.join(workspace, name);
26108
+ if (!import_fs_extra19.default.existsSync(skillDir)) {
22644
26109
  logError(`Skill directory does not exist: ${skillDir}`);
22645
26110
  return;
22646
26111
  }
22647
- const { scope } = await import_inquirer2.default.prompt([
26112
+ const { scope } = await import_inquirer3.default.prompt([
22648
26113
  {
22649
26114
  type: "list",
22650
26115
  name: "scope",
@@ -22656,17 +26121,17 @@ async function handleSkillsAdd(name) {
22656
26121
  }
22657
26122
  ]);
22658
26123
  const homePath = getHomePath();
22659
- const globalSkillDir = import_path14.default.join(homePath, "skills");
22660
- const localSkillDir = import_path14.default.join(workspace, ".deepfish", "skills");
26124
+ const globalSkillDir = import_path19.default.join(homePath, "skills");
26125
+ const localSkillDir = import_path19.default.join(workspace, ".deepfish-ai", "skills");
22661
26126
  if (scope === "local") {
22662
- import_fs_extra12.default.ensureDirSync(localSkillDir);
26127
+ import_fs_extra19.default.ensureDirSync(localSkillDir);
22663
26128
  } else {
22664
- import_fs_extra12.default.ensureDirSync(globalSkillDir);
26129
+ import_fs_extra19.default.ensureDirSync(globalSkillDir);
22665
26130
  }
22666
26131
  const targetDir = scope === "local" ? localSkillDir : globalSkillDir;
22667
- const targetPath = import_path14.default.join(targetDir, name);
22668
- if (import_fs_extra12.default.existsSync(targetPath)) {
22669
- const { overwrite } = await import_inquirer2.default.prompt([
26132
+ const targetPath = import_path19.default.join(targetDir, name);
26133
+ if (import_fs_extra19.default.existsSync(targetPath)) {
26134
+ const { overwrite } = await import_inquirer3.default.prompt([
22670
26135
  {
22671
26136
  type: "confirm",
22672
26137
  name: "overwrite",
@@ -22678,9 +26143,9 @@ async function handleSkillsAdd(name) {
22678
26143
  logWarning("Add cancelled");
22679
26144
  return;
22680
26145
  }
22681
- import_fs_extra12.default.removeSync(targetPath);
26146
+ import_fs_extra19.default.removeSync(targetPath);
22682
26147
  }
22683
- import_fs_extra12.default.moveSync(skillDir, targetPath, { overwrite: true });
26148
+ import_fs_extra19.default.moveSync(skillDir, targetPath, { overwrite: true });
22684
26149
  logSuccess(`Skill ${scope === "local" ? "locally" : "globally"} added: ${targetPath}`);
22685
26150
  _updateRegister(targetDir);
22686
26151
  }
@@ -22692,13 +26157,13 @@ function handleSkillsDel(index) {
22692
26157
  return;
22693
26158
  }
22694
26159
  const skill = skills[skillIndex];
22695
- import_fs_extra12.default.removeSync(skill.skillPath);
26160
+ import_fs_extra19.default.removeSync(skill.skillPath);
22696
26161
  const skillDir = skill.skillDir;
22697
- const registerPath = import_path14.default.join(skillDir, "skills", "register.json");
22698
- if (import_fs_extra12.default.existsSync(registerPath)) {
22699
- let register = import_fs_extra12.default.readJSONSync(registerPath);
26162
+ const registerPath = import_path19.default.join(skillDir, "skills", "register.json");
26163
+ if (import_fs_extra19.default.existsSync(registerPath)) {
26164
+ let register = import_fs_extra19.default.readJSONSync(registerPath);
22700
26165
  register = register.filter((item) => item.skillPath !== skill.skillPath);
22701
- import_fs_extra12.default.writeJSONSync(registerPath, register, { spaces: 2 });
26166
+ import_fs_extra19.default.writeJSONSync(registerPath, register, { spaces: 2 });
22702
26167
  }
22703
26168
  logSuccess(`Skill \u5220\u9664: ${skill.name}`);
22704
26169
  }
@@ -22712,8 +26177,8 @@ function handleSkillsEnable(index) {
22712
26177
  const skill = skills[skillIndex];
22713
26178
  skill.isEnabled = true;
22714
26179
  const skillDir = skill.skillDir;
22715
- const registerPath = import_path14.default.join(skillDir, "skills", "register.json");
22716
- import_fs_extra12.default.writeJSONSync(
26180
+ const registerPath = import_path19.default.join(skillDir, "skills", "register.json");
26181
+ import_fs_extra19.default.writeJSONSync(
22717
26182
  registerPath,
22718
26183
  skills.filter((item) => item.skillDir === skillDir),
22719
26184
  { spaces: 2 }
@@ -22730,8 +26195,8 @@ function handleSkillsDisable(index) {
22730
26195
  const skill = skills[skillIndex];
22731
26196
  skill.isEnabled = false;
22732
26197
  const skillDir = skill.skillDir;
22733
- const registerPath = import_path14.default.join(skillDir, "skills", "register.json");
22734
- import_fs_extra12.default.writeJSONSync(
26198
+ const registerPath = import_path19.default.join(skillDir, "skills", "register.json");
26199
+ import_fs_extra19.default.writeJSONSync(
22735
26200
  registerPath,
22736
26201
  skills.filter((item) => item.skillDir === skillDir),
22737
26202
  { spaces: 2 }
@@ -22741,7 +26206,7 @@ function handleSkillsDisable(index) {
22741
26206
  function handleSkillsDir() {
22742
26207
  logInfo("Opening skills directory");
22743
26208
  const homePath = getHomePath();
22744
- const globalSkillDir = import_path14.default.join(homePath, "skills");
26209
+ const globalSkillDir = import_path19.default.join(homePath, "skills");
22745
26210
  openDirectory(globalSkillDir);
22746
26211
  }
22747
26212
  async function handleSkillsGenerate(target) {
@@ -22756,7 +26221,7 @@ async function handleSkillsGenerate(target) {
22756
26221
  }
22757
26222
  const currentModelName = config2.currentModel;
22758
26223
  if (!currentModelName) {
22759
- logError("No AI model configured, please run ai model use <\u540D\u79F0>");
26224
+ logError("No AI model configured, please run ai model use <name>");
22760
26225
  return;
22761
26226
  }
22762
26227
  try {
@@ -22765,7 +26230,7 @@ async function handleSkillsGenerate(target) {
22765
26230
  logError("Failed to start service, please check config or port availability");
22766
26231
  return;
22767
26232
  }
22768
- const generateSkillPath = import_path14.default.join(__dirname, "./generate-skill.md");
26233
+ const generateSkillPath = import_path19.default.join(__dirname, "./generate-skill.md");
22769
26234
  const agent = await initAgent(config2, [generateSkillPath]);
22770
26235
  const prompt = `\u8BF7\u6839\u636E\u4EE5\u4E0B\u9700\u6C42\u751F\u6210\u4E00\u4E2ASkill\u6A21\u5757\uFF1A${target}
22771
26236
 
@@ -22783,13 +26248,13 @@ async function handleSkillsGenerate(target) {
22783
26248
  }
22784
26249
  function _scanSkills(skillsDir) {
22785
26250
  const skills = [];
22786
- if (import_fs_extra12.default.existsSync(skillsDir)) {
22787
- const files = import_fs_extra12.default.readdirSync(skillsDir);
26251
+ if (import_fs_extra19.default.existsSync(skillsDir)) {
26252
+ const files = import_fs_extra19.default.readdirSync(skillsDir);
22788
26253
  files.forEach((file2) => {
22789
- const filePath = import_path14.default.resolve(skillsDir, file2);
22790
- if (import_fs_extra12.default.statSync(filePath).isDirectory()) {
22791
- const skillMdPath = import_path14.default.resolve(filePath, "SKILL.md");
22792
- if (import_fs_extra12.default.existsSync(skillMdPath)) {
26254
+ const filePath = import_path19.default.resolve(skillsDir, file2);
26255
+ if (import_fs_extra19.default.statSync(filePath).isDirectory()) {
26256
+ const skillMdPath = import_path19.default.resolve(filePath, "SKILL.md");
26257
+ if (import_fs_extra19.default.existsSync(skillMdPath)) {
22793
26258
  skills.push(filePath);
22794
26259
  }
22795
26260
  }
@@ -22798,17 +26263,17 @@ function _scanSkills(skillsDir) {
22798
26263
  return skills;
22799
26264
  }
22800
26265
  function _updateRegister(skillsDir) {
22801
- const registerPath = import_path14.default.resolve(skillsDir, "register.json");
22802
- if (import_fs_extra12.default.existsSync(skillsDir) && !import_fs_extra12.default.existsSync(registerPath)) {
22803
- import_fs_extra12.default.writeJSONSync(registerPath, [], { spaces: 2 });
22804
- } else if (!import_fs_extra12.default.existsSync(skillsDir)) {
26266
+ const registerPath = import_path19.default.resolve(skillsDir, "register.json");
26267
+ if (import_fs_extra19.default.existsSync(skillsDir) && !import_fs_extra19.default.existsSync(registerPath)) {
26268
+ import_fs_extra19.default.writeJSONSync(registerPath, [], { spaces: 2 });
26269
+ } else if (!import_fs_extra19.default.existsSync(skillsDir)) {
22805
26270
  return;
22806
26271
  }
22807
26272
  const skills = _scanSkills(skillsDir);
22808
- let register = import_fs_extra12.default.readJSONSync(registerPath);
26273
+ let register = import_fs_extra19.default.readJSONSync(registerPath);
22809
26274
  const newRegister = [];
22810
26275
  skills.forEach((skillPath) => {
22811
- const skillName = import_path14.default.basename(skillPath);
26276
+ const skillName = import_path19.default.basename(skillPath);
22812
26277
  const existItem = register.find((item) => item.skillPath === skillPath);
22813
26278
  if (!existItem) {
22814
26279
  newRegister.push({
@@ -22821,16 +26286,16 @@ function _updateRegister(skillsDir) {
22821
26286
  });
22822
26287
  register = register.filter((item) => skills.includes(item.skillPath));
22823
26288
  register.push(...newRegister);
22824
- import_fs_extra12.default.writeJSONSync(registerPath, register, { spaces: 2 });
26289
+ import_fs_extra19.default.writeJSONSync(registerPath, register, { spaces: 2 });
22825
26290
  }
22826
26291
  function getRegisteredSkills() {
22827
26292
  const scanPaths = getScanDirPaths();
22828
26293
  const skills = [];
22829
26294
  scanPaths.forEach((scanPath) => {
22830
26295
  _updateRegister(scanPath);
22831
- const registerPath = import_path14.default.join(scanPath, "skills", "register.json");
22832
- if (import_fs_extra12.default.existsSync(registerPath)) {
22833
- const register = import_fs_extra12.default.readJSONSync(registerPath);
26296
+ const registerPath = import_path19.default.join(scanPath, "skills", "register.json");
26297
+ if (import_fs_extra19.default.existsSync(registerPath)) {
26298
+ const register = import_fs_extra19.default.readJSONSync(registerPath);
22834
26299
  register.forEach((item) => {
22835
26300
  if (item.isEnabled) {
22836
26301
  skills.push(item.skillPath);
@@ -22842,10 +26307,10 @@ function getRegisteredSkills() {
22842
26307
  }
22843
26308
  function _getSkillList(skillsDir) {
22844
26309
  let allSkills = [];
22845
- const registerPath = import_path14.default.join(skillsDir, "skills", "register.json");
22846
- if (import_fs_extra12.default.existsSync(registerPath)) {
26310
+ const registerPath = import_path19.default.join(skillsDir, "skills", "register.json");
26311
+ if (import_fs_extra19.default.existsSync(registerPath)) {
22847
26312
  _updateRegister(skillsDir);
22848
- const register = import_fs_extra12.default.readJSONSync(registerPath);
26313
+ const register = import_fs_extra19.default.readJSONSync(registerPath);
22849
26314
  allSkills = allSkills.concat(register);
22850
26315
  }
22851
26316
  return allSkills;
@@ -22868,7 +26333,7 @@ function _getAllSkills() {
22868
26333
  function registerSkillsCommands(program) {
22869
26334
  const skills = program.command("skills");
22870
26335
  skills.command("ls").description("\u5217\u51FA\u6240\u6709\u6280\u80FD").action(handleSkillsLs);
22871
- skills.command("add <name>").description("\u6DFB\u52A0\u672C\u5730\u6280\u80FD\u76EE\u5F55\u6216 zip \u6587\u4EF6").action(handleSkillsAdd);
26336
+ skills.command("add <name>").description("\u6DFB\u52A0\u672C\u5730\u6280\u80FD\u76EE\u5F55").action(handleSkillsAdd);
22872
26337
  skills.command("del <index>").description("\u6309\u7D22\u5F15\u5220\u9664\u6280\u80FD").action(handleSkillsDel);
22873
26338
  skills.command("enable <index>").description("\u6309\u7D22\u5F15\u542F\u7528\u6280\u80FD").action(handleSkillsEnable);
22874
26339
  skills.command("disable <index>").description("\u6309\u7D22\u5F15\u7981\u7528\u6280\u80FD").action(handleSkillsDisable);
@@ -22877,12 +26342,57 @@ function registerSkillsCommands(program) {
22877
26342
  }
22878
26343
 
22879
26344
  // src/cli/cli-core/tools.ts
22880
- var import_path15 = __toESM(require("path"));
26345
+ var import_inquirer4 = __toESM(require("inquirer"));
26346
+ var import_fs_extra20 = __toESM(require("fs-extra"));
26347
+ var import_path20 = __toESM(require("path"));
22881
26348
  function handleToolsDir() {
22882
26349
  const toolsPath = getToolsPath();
22883
26350
  openDirectory(toolsPath);
22884
26351
  logSuccess("Tools directory opened");
22885
26352
  }
26353
+ async function handleToolsAdd(name) {
26354
+ logInfo(`Adding tool: ${name}`);
26355
+ const workspace = getWorkspacePath();
26356
+ const toolDir = import_path20.default.join(workspace, name);
26357
+ if (!import_fs_extra20.default.existsSync(toolDir)) {
26358
+ logError(`Tool directory does not exist: ${toolDir}`);
26359
+ return;
26360
+ }
26361
+ const { scope } = await import_inquirer4.default.prompt([
26362
+ {
26363
+ type: "list",
26364
+ name: "scope",
26365
+ message: "Select tool scope:",
26366
+ choices: [
26367
+ { name: "Local (current workspace only)", value: "local" },
26368
+ { name: "Global (available to all workspaces)", value: "global" }
26369
+ ]
26370
+ }
26371
+ ]);
26372
+ const homePath = getHomePath();
26373
+ const globalToolDir = import_path20.default.join(homePath, "tools");
26374
+ const localToolDir = import_path20.default.join(workspace, ".deepfish-ai", "tools");
26375
+ const targetDir = scope === "local" ? localToolDir : globalToolDir;
26376
+ const targetPath = import_path20.default.join(targetDir, name);
26377
+ import_fs_extra20.default.ensureDirSync(targetDir);
26378
+ if (import_fs_extra20.default.existsSync(targetPath)) {
26379
+ const { overwrite } = await import_inquirer4.default.prompt([
26380
+ {
26381
+ type: "confirm",
26382
+ name: "overwrite",
26383
+ message: `A tool named "${name}" already exists at the target location. Overwrite?`,
26384
+ default: false
26385
+ }
26386
+ ]);
26387
+ if (!overwrite) {
26388
+ logWarning("Add cancelled");
26389
+ return;
26390
+ }
26391
+ import_fs_extra20.default.removeSync(targetPath);
26392
+ }
26393
+ import_fs_extra20.default.moveSync(toolDir, targetPath, { overwrite: true });
26394
+ logSuccess(`Tool ${scope === "local" ? "locally" : "globally"} added: ${targetPath}`);
26395
+ }
22886
26396
  async function handleToolsGenerate(target) {
22887
26397
  if (!target.trim()) {
22888
26398
  logError('Please provide a tool description, e.g.: ai tools generate "a weather query tool"');
@@ -22904,7 +26414,7 @@ async function handleToolsGenerate(target) {
22904
26414
  logError("Failed to start service, please check config or port availability");
22905
26415
  return;
22906
26416
  }
22907
- const generateSkillPath = import_path15.default.join(__dirname, "./generate-tool.md");
26417
+ const generateSkillPath = import_path20.default.join(__dirname, "./generate-tool.md");
22908
26418
  const agent = await initAgent(config2, [generateSkillPath]);
22909
26419
  const prompt = `Please use the "generate-tool" SKILL to generate a tool module according to the following requirements: ${target}
22910
26420
 
@@ -22924,6 +26434,7 @@ async function handleToolsGenerate(target) {
22924
26434
  function registerToolsCommands(program) {
22925
26435
  const tools = program.command("tools");
22926
26436
  tools.command("dir").description("\u6253\u5F00\u5DE5\u5177\u76EE\u5F55").action(handleToolsDir);
26437
+ tools.command("add <name>").description("\u6DFB\u52A0\u672C\u5730\u5DE5\u5177\u76EE\u5F55").action(handleToolsAdd);
22927
26438
  tools.command("generate <target>").description("\u751F\u6210\u5DE5\u5177").action(handleToolsGenerate);
22928
26439
  }
22929
26440
 
@@ -23049,7 +26560,7 @@ function registerMcpCommands(program) {
23049
26560
  }
23050
26561
 
23051
26562
  // src/cli/cli-core/input.ts
23052
- var import_fs_extra13 = __toESM(require("fs-extra"));
26563
+ var import_fs_extra21 = __toESM(require("fs-extra"));
23053
26564
  var readline = __toESM(require("readline"));
23054
26565
  async function handleInput(args) {
23055
26566
  const input = args.join(" ");
@@ -23059,14 +26570,14 @@ async function handleInput(args) {
23059
26570
  }
23060
26571
  try {
23061
26572
  const configPath = getConfigPath();
23062
- if (!import_fs_extra13.default.pathExistsSync(configPath)) {
26573
+ if (!import_fs_extra21.default.pathExistsSync(configPath)) {
23063
26574
  logError("Config file not found, please run init first");
23064
26575
  return;
23065
26576
  }
23066
26577
  const config2 = getConfig();
23067
26578
  const currentModelName = config2.currentModel;
23068
26579
  if (!currentModelName) {
23069
- logError("No AI model configured, please run ai model use <\u540D\u79F0>");
26580
+ logError("No AI model configured, please run ai model use <name>");
23070
26581
  return;
23071
26582
  }
23072
26583
  const isServerRunning2 = await testServer();
@@ -23096,14 +26607,14 @@ async function handleInput(args) {
23096
26607
  async function multiInput() {
23097
26608
  try {
23098
26609
  const configPath = getConfigPath();
23099
- if (!import_fs_extra13.default.pathExistsSync(configPath)) {
26610
+ if (!import_fs_extra21.default.pathExistsSync(configPath)) {
23100
26611
  logError("Config file not found, please run init first");
23101
26612
  return;
23102
26613
  }
23103
26614
  const config2 = getConfig();
23104
26615
  const currentModelName = config2.currentModel;
23105
26616
  if (!currentModelName) {
23106
- logError("No AI model configured, please run ai model use <\u540D\u79F0>");
26617
+ logError("No AI model configured, please run ai model use <name>");
23107
26618
  return;
23108
26619
  }
23109
26620
  const isServerRunning2 = await testServer();
@@ -23115,7 +26626,7 @@ async function multiInput() {
23115
26626
  const connResult = await connectAgentRoom(agent);
23116
26627
  if (!connResult.ok) {
23117
26628
  if (connResult.reason === "duplicate-id") {
23118
- logWarning(`[agent-room] agent "${agent.id}" is already running, task added to queue`);
26629
+ logWarning(`[agent-room] agent "${agent.id}" is already running`);
23119
26630
  return null;
23120
26631
  } else {
23121
26632
  logWarning("[agent-room] agent-room service not detected, running in offline mode");
@@ -23166,7 +26677,7 @@ function registerInputCommand(program) {
23166
26677
  }
23167
26678
 
23168
26679
  // src/cli/cli-core/cache.ts
23169
- var import_path16 = __toESM(require("path"));
26680
+ var import_path21 = __toESM(require("path"));
23170
26681
  var userCache2 = new UserCache();
23171
26682
  function resolveId(input) {
23172
26683
  const index = Number(input);
@@ -23200,7 +26711,7 @@ function handleCacheList() {
23200
26711
  function handleCacheEdit(input) {
23201
26712
  const id = resolveId(input);
23202
26713
  if (!id) return;
23203
- const filePath = import_path16.default.join(getUserStorePath(), `${id}.md`);
26714
+ const filePath = import_path21.default.join(getUserStorePath(), `${id}.md`);
23204
26715
  editFile(filePath);
23205
26716
  }
23206
26717
  function handleCacheDel(input) {
@@ -23238,56 +26749,56 @@ function helpInformation() {
23238
26749
  return `Usage: ai [options] [command]
23239
26750
 
23240
26751
  Commands:
23241
- ai "xxx"
26752
+ ai "xxx" \u76F4\u63A5\u5411 AI \u53D1\u8D77\u4E00\u6B21\u4EFB\u52A1\u6216\u5BF9\u8BDD
23242
26753
 
23243
26754
  # Configuration commands
23244
- ai config edit
23245
- ai config view
23246
- ai config reset
23247
- ai config dir
26755
+ ai config edit \u6253\u5F00\u5168\u5C40\u914D\u7F6E\u6587\u4EF6\u8FDB\u884C\u7F16\u8F91
26756
+ ai config view \u67E5\u770B\u5F53\u524D\u5168\u5C40\u914D\u7F6E\u5185\u5BB9
26757
+ ai config reset \u91CD\u7F6E\u5168\u5C40\u914D\u7F6E\u4E3A\u9ED8\u8BA4\u503C
26758
+ ai config dir \u6253\u5F00\u6216\u8F93\u51FA\u5168\u5C40\u914D\u7F6E\u76EE\u5F55
23248
26759
 
23249
26760
  # Model commands
23250
- ai models add
23251
- ai models ls
23252
- ai models use <name>
23253
- ai models del <name>
26761
+ ai models add \u6DFB\u52A0\u4E00\u4E2A\u65B0\u7684\u6A21\u578B\u914D\u7F6E
26762
+ ai models ls \u67E5\u770B\u5DF2\u914D\u7F6E\u7684\u6A21\u578B\u5217\u8868
26763
+ ai models use <name> \u5207\u6362\u5F53\u524D\u9ED8\u8BA4\u4F7F\u7528\u7684\u6A21\u578B
26764
+ ai models del <name> \u5220\u9664\u6307\u5B9A\u540D\u79F0\u7684\u6A21\u578B\u914D\u7F6E
23254
26765
 
23255
26766
  # Skill commands
23256
- ai skills ls
23257
- ai skills add <name>
23258
- ai skills del <index>
23259
- ai skills enable <name|index>
23260
- ai skills disable <name|index>
23261
- ai skills dir
23262
- ai skills generate xxx
26767
+ ai skills ls \u67E5\u770B\u5DF2\u5B89\u88C5\u6216\u5DF2\u914D\u7F6E\u7684\u6280\u80FD\u5217\u8868
26768
+ ai skills add <name> \u6DFB\u52A0\u6307\u5B9A\u540D\u79F0\u7684\u6280\u80FD
26769
+ ai skills del <index> \u5220\u9664\u6307\u5B9A\u5E8F\u53F7\u7684\u6280\u80FD
26770
+ ai skills enable <name|index> \u542F\u7528\u6307\u5B9A\u540D\u79F0\u6216\u5E8F\u53F7\u7684\u6280\u80FD
26771
+ ai skills disable <name|index> \u7981\u7528\u6307\u5B9A\u540D\u79F0\u6216\u5E8F\u53F7\u7684\u6280\u80FD
26772
+ ai skills dir \u6253\u5F00\u6216\u8F93\u51FA\u6280\u80FD\u76EE\u5F55
26773
+ ai skills generate xxx \u6839\u636E\u63CF\u8FF0\u751F\u6210\u4E00\u4E2A\u65B0\u7684\u6280\u80FD\u6A21\u677F
23263
26774
 
23264
26775
  # Tools commands
23265
- ai tools dir
23266
- ai tools generate xxx
26776
+ ai tools dir \u6253\u5F00\u6216\u8F93\u51FA\u7528\u6237\u81EA\u5B9A\u4E49\u5DE5\u5177\u76EE\u5F55
26777
+ ai tools generate xxx \u6839\u636E\u63CF\u8FF0\u751F\u6210\u4E00\u4E2A\u65B0\u7684\u5DE5\u5177\u6A21\u677F
23267
26778
 
23268
26779
  # Session commands
23269
- ai session clear
23270
- ai session dir
26780
+ ai session clear \u6E05\u7A7A\u5F53\u524D\u4F1A\u8BDD\u8BB0\u5F55
26781
+ ai session dir \u6253\u5F00\u6216\u8F93\u51FA\u4F1A\u8BDD\u6570\u636E\u76EE\u5F55
23271
26782
 
23272
26783
  # Task commands
23273
- ai task ls
23274
- ai task add <task>
23275
- ai task del <index>
23276
- ai task clear
26784
+ ai task ls \u67E5\u770B\u5F53\u524D\u4EFB\u52A1\u961F\u5217
26785
+ ai task add <task> \u5411\u4EFB\u52A1\u961F\u5217\u6DFB\u52A0\u4E00\u4E2A\u540E\u7EED\u4EFB\u52A1
26786
+ ai task del <index> \u5220\u9664\u6307\u5B9A\u5E8F\u53F7\u7684\u4EFB\u52A1
26787
+ ai task clear \u6E05\u7A7A\u5F53\u524D\u4EFB\u52A1\u961F\u5217
23277
26788
 
23278
26789
  # MCP commands
23279
- ai mcp edit
26790
+ ai mcp edit \u6253\u5F00 MCP \u914D\u7F6E\u6587\u4EF6\u8FDB\u884C\u7F16\u8F91
23280
26791
 
23281
26792
  # Serve commands
23282
- ai serve
23283
- ai serve start
23284
- ai serve stop
23285
- ai serve restart
26793
+ ai serve \u542F\u52A8\u670D\u52A1\u6216\u8FDB\u5165\u670D\u52A1\u7BA1\u7406\u5165\u53E3
26794
+ ai serve start \u542F\u52A8\u540E\u53F0\u670D\u52A1
26795
+ ai serve stop \u505C\u6B62\u540E\u53F0\u670D\u52A1
26796
+ ai serve restart \u91CD\u542F\u540E\u53F0\u670D\u52A1
23286
26797
 
23287
26798
  # Cache commands
23288
- ai cache ls
23289
- ai cache edit <index|id>
23290
- ai cache del <index|id>
26799
+ ai cache ls \u67E5\u770B\u5DF2\u7F13\u5B58\u7684\u5B66\u4E60\u5185\u5BB9\u5217\u8868
26800
+ ai cache edit <index|id> \u7F16\u8F91\u6307\u5B9A\u5E8F\u53F7\u6216 ID \u7684\u7F13\u5B58\u5185\u5BB9
26801
+ ai cache del <index|id> \u5220\u9664\u6307\u5B9A\u5E8F\u53F7\u6216 ID \u7684\u7F13\u5B58\u5185\u5BB9
23291
26802
  `;
23292
26803
  }
23293
26804
  function registerHelpCommand(program) {